Skip to content

Commit

Permalink
Add method to know if message is compatible with given client
Browse files Browse the repository at this point in the history
  • Loading branch information
zio-mitch committed Oct 15, 2024
1 parent 64adfce commit 4f51112
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/RawMailerSdk/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,23 @@ private function send(

return $this->smtpClient->send($message);
}

/**
* @param MailerInterface $client
* @param SmtpMessage $message
*
* @return void
*
* @throws MessageSizeException, if the message is not compatible with the given client
*/
public static function assertMessageDriverCompatible(MailerInterface $client, SmtpMessage $message): void
{
$messageSize = $message->getAttachmentsSize();

if ($client instanceof SesClientFacade && $messageSize > static::MAX_ATTACHMENT_SIZE_AWS_SES) {
throw new MessageSizeException($messageSize, static::MAX_ATTACHMENT_SIZE_AWS_SES, static::DRIVERS['SES'], static::DRIVERS['STD']);
} else if ($client instanceof SwiftMailerClientFacade && $messageSize > static::MAX_ATTACHMENT_SIZE_SMTP) {
throw new MessageSizeException($messageSize, static::MAX_ATTACHMENT_SIZE_SMTP, static::DRIVERS['SES'], null);
}
}
}

0 comments on commit 4f51112

Please sign in to comment.