Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Implement email "metadata" for SesTransport #41422

Merged
merged 1 commit into from Mar 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Illuminate/Mail/Transport/SesTransport.php
Expand Up @@ -5,8 +5,10 @@
use Aws\Exception\AwsException;
use Aws\Ses\SesClient;
use Exception;
use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mailer\SentMessage;
use Symfony\Component\Mailer\Transport\AbstractTransport;
use Symfony\Component\Mime\Message;

class SesTransport extends AbstractTransport
{
Expand Down Expand Up @@ -44,10 +46,20 @@ public function __construct(SesClient $ses, $options = [])
*/
protected function doSend(SentMessage $message): void
{
$options = $this->options;

if ($message->getOriginalMessage() instanceof Message) {
foreach ($message->getOriginalMessage()->getHeaders()->all() as $header) {
if ($header instanceof MetadataHeader) {
$options['EmailTags'][] = ['Name' => $header->getKey(), 'Value' => $header->getValue()];
}
}
}

try {
$this->ses->sendRawEmail(
array_merge(
$this->options, [
$options, [
'Source' => $message->getEnvelope()->getSender()->toString(),
'Destinations' => collect($message->getEnvelope()->getRecipients())
->map
Expand Down