Skip to content

Commit 0b866d5

Browse files
authored
Merge pull request #102 from utopia-php/remove-default-recipient
chore: remove default recepient
2 parents 0d364ed + 71e6afa commit 0b866d5

3 files changed

Lines changed: 0 additions & 17 deletions

File tree

src/Utopia/Messaging/Adapter/Email/SMTP.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ protected function process(EmailMessage $message): array
7575
$mail->AltBody = \strip_tags($mail->AltBody);
7676
$mail->AltBody = \trim($mail->AltBody);
7777

78-
if (empty($message->getTo())) {
79-
if (empty($message->getBCC()) && empty($message->getDefaultRecipient())) {
80-
throw new \Exception('Email requires either "to" recipients or both BCC and a default recipient configurations');
81-
}
82-
83-
$mail->addAddress($message->getDefaultRecipient());
84-
}
85-
8678
foreach ($message->getTo() as $to) {
8779
$mail->addAddress($to);
8880
}

src/Utopia/Messaging/Messages/Email.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class Email implements Message
1919
* @param string|null $replyToEmail The email address of the reply to.
2020
* @param array<Attachment>|null $attachments The attachments of the email.
2121
* @param bool $html Whether the message is HTML or not.
22-
* @param string|null $defaultRecipient The default recipient of the email.
2322
*
2423
* @throws \InvalidArgumentException
2524
*/
@@ -35,7 +34,6 @@ public function __construct(
3534
private ?array $bcc = null,
3635
private ?array $attachments = null,
3736
private bool $html = false,
38-
private ?string $defaultRecipient = null
3937
) {
4038
if (\is_null($this->replyToName)) {
4139
$this->replyToName = $this->fromName;
@@ -128,9 +126,4 @@ public function isHtml(): bool
128126
{
129127
return $this->html;
130128
}
131-
132-
public function getDefaultRecipient(): ?string
133-
{
134-
return $this->defaultRecipient;
135-
}
136129
}

tests/Messaging/Adapter/Email/SMTPTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public function testSendEmailOnlyBCC(): void
8585
port: 1025,
8686
);
8787

88-
$defaultRecipient = 'tester@localhost.test';
8988
$subject = 'Test Subject';
9089
$content = 'Test Content';
9190
$fromName = 'Test Sender';
@@ -104,7 +103,6 @@ public function testSendEmailOnlyBCC(): void
104103
fromName: $fromName,
105104
fromEmail: $fromEmail,
106105
bcc: $bcc,
107-
defaultRecipient: $defaultRecipient,
108106
);
109107

110108
$response = $sender->send($message);

0 commit comments

Comments
 (0)