ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
Mb3SafeMailEncoder.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
20 namespace ILIAS\Mail\Object;
21 
22 final class Mb3SafeMailEncoder implements MailPayloadEncoder
23 {
24  public function __construct(
25  private readonly MailPayloadEncoder $inner,
26  private readonly \ILIAS\Mail\Transformation\Utf8Mb4Sanitizer $trafo
27  ) {
28  }
29 
30  public function encode(array $mails): string
31  {
32  $sanitized = [];
33  foreach ($mails as $m) {
34  $sanitized[] = new \ilMailValueObject(
35  $m->getFrom(),
36  $m->getRecipients(),
37  $m->getRecipientsCC(),
38  $m->getRecipientsBCC(),
39  $this->trafo->transform($m->getSubject()),
40  $this->trafo->transform($m->getBody()),
41  $m->getAttachments(),
42  $m->isUsingPlaceholders(),
43  $m->shouldSaveInSentBox()
44  );
45  }
46 
47  return $this->inner->encode($sanitized);
48  }
49 }
Interface Observer Contains several chained tasks and infos about them.
__construct(private readonly MailPayloadEncoder $inner, private readonly \ILIAS\Mail\Transformation\Utf8Mb4Sanitizer $trafo)
RFC 822 Email address list validation Utility.