|
|
@@ -18,6 +18,8 @@ final class MimeMailBuilder
|
|
|
private string $textBody = '';
|
|
|
/** @var array<int, array{path: string, name: string, mime: string}> */
|
|
|
private array $attachments = [];
|
|
|
+ /** @var array<int, string> */
|
|
|
+ private array $cc = [];
|
|
|
private string $errorInfo = '';
|
|
|
|
|
|
public function setFrom(string $address, string $name = ''): self
|
|
|
@@ -33,6 +35,15 @@ final class MimeMailBuilder
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
+ public function addCc(string $address): self
|
|
|
+ {
|
|
|
+ $sanitized = $this->sanitizeAddress($address);
|
|
|
+ if ($sanitized !== '') {
|
|
|
+ $this->cc[] = $sanitized;
|
|
|
+ }
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
public function setSubject(string $subject): self
|
|
|
{
|
|
|
$this->subject = $this->sanitizeHeaderText($subject);
|
|
|
@@ -111,11 +122,17 @@ final class MimeMailBuilder
|
|
|
|
|
|
$type = $isMixed ? 'multipart/mixed' : 'multipart/alternative';
|
|
|
|
|
|
- return implode("\r\n", [
|
|
|
+ $headers = [
|
|
|
'From: ' . $from,
|
|
|
'MIME-Version: 1.0',
|
|
|
'Content-Type: ' . $type . '; boundary="' . $boundary . '"',
|
|
|
- ]);
|
|
|
+ ];
|
|
|
+
|
|
|
+ if ($this->cc !== []) {
|
|
|
+ $headers[] = 'Cc: ' . implode(', ', $this->cc);
|
|
|
+ }
|
|
|
+
|
|
|
+ return implode("\r\n", $headers);
|
|
|
}
|
|
|
|
|
|
private function buildMixedBody(string $mixedBoundary, string $altBoundary): string
|