Skip to content

Commit

Permalink
Merge pull request #33 from PhantPHP/email-add-cc-and-bcc
Browse files Browse the repository at this point in the history
Email : Add cc and bcc
  • Loading branch information
lennyrouanet authored Mar 27, 2024
2 parents acd4253 + 957b0eb commit 0466855
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions component/Web/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ final public function __construct(
public string $messageHtml,
public EmailAddressAndName $from,
public EmailAddressAndNameList $to,
public ?EmailAddressAndNameList $cc,
public ?EmailAddressAndNameList $bcc,
public ?EmailAddressAndName $replyTo = null,
public ?EmailAttachmentList $attachmentList = null
) {
Expand Down Expand Up @@ -46,6 +48,8 @@ public static function make(
$toName
)
),
null,
null,
$replyToEmailAddress ? EmailAddressAndName::make(
$replyToEmailAddress,
$replyToName
Expand Down
24 changes: 24 additions & 0 deletions test/Web/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ public function testInterface(): void
'John DOE'
)
),
(new EmailAddressAndNameList())->add(
new EmailAddressAndName(
new EmailAddress('[email protected]'),
'John DOE'
)
),
(new EmailAddressAndNameList())->add(
new EmailAddressAndName(
new EmailAddress('[email protected]'),
'John DOE'
)
),
new EmailAddressAndName(
new EmailAddress('[email protected]'),
'No reply'
Expand Down Expand Up @@ -73,6 +85,18 @@ public function testInterface(): void
$this->assertEquals('[email protected]', (string)$to->emailAddress);
$this->assertEquals('John DOE', $to->name);

$this->assertIsObject($email->cc);
$this->assertInstanceOf(EmailAddressAndNameList::class, $email->cc);
$cc = $email->cc->itemsIterator()->current();
$this->assertEquals('[email protected]', (string)$cc->emailAddress);
$this->assertEquals('John DOE', $cc->name);

$this->assertIsObject($email->bcc);
$this->assertInstanceOf(EmailAddressAndNameList::class, $email->bcc);
$bcc = $email->bcc->itemsIterator()->current();
$this->assertEquals('[email protected]', (string)$bcc->emailAddress);
$this->assertEquals('John DOE', $bcc->name);

$this->assertIsObject($email->replyTo);
$this->assertInstanceOf(EmailAddressAndName::class, $email->replyTo);
$this->assertEquals('[email protected]', (string)$email->replyTo->emailAddress);
Expand Down

0 comments on commit 0466855

Please sign in to comment.