The first failover driver is mailgun, the second is Amazon SES
and when the Mailgun failed I found The Amazon SES email image src is wrong can’t show on email
first image normal email source is here
the driver version is here
symfony/mailer 6.4.8
symfony/mailgun-mailer 7.1.1
Content-Type: multipart/related;
...
<img id=3D"logo" width=3D"190" height=3D"40" style=3D"width:=
190px; height: 40px; -ms-interpolation-mode: bicubic;" src=3D"cid:d3a788f4cbf3a6aab32dcacde69a2e34@symfony" alt=3D"">
....
--KGCwwzRU
Content-ID: d3a788f4cbf3a6aab32dcacde69a2e34@symfony
Content-Type: image/png; name="d3a788f4cbf3a6aab32dcacde69a2e34@symfony"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
name="d3a788f4cbf3a6aab32dcacde69a2e34@symfony"; filename=V9J4rKBvmB
second image src is wrong can’t display. and email source is here
Content-Type: multipart/mixed;
<img id=3D"logo" width=3D"190" height=3D"40" style=3D"width:=
190px; height: 40px; -ms-interpolation-mode: bicubic;" src=3D"cid:L7HALxfBwi" alt=3D"">
...
--TG5g10Dt
Content-ID: 2eabc9240b3557c72ad65e92a60f7f57@symfony
Content-Type: image/png; name="2eabc9240b3557c72ad65e92a60f7f57@symfony"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
name="2eabc9240b3557c72ad65e92a60f7f57@symfony"; filename=L7HALxfBwi
i use symfony mailer in laravel 10
here is the fake code
sorry about demo code
config()->set('mail.mailers.failover.mailers', ['mailgun', 'ses']);
$mail_manager = app()->get('mail.manager');
$mail_manager->setSymfonyTransport($mail_manager->createSymfonyTransport(config('mail.mailers.failover')));
Mail::mailer($driver)->send(new MailableView(1, "The $driver mailable view test email"));
use IlluminateMailMailable
class Mailable extends IlluminateMailable
$this->view('emails.mailable_view_test.email_view')
->text('emails.mailable_view_test.email_view_text')
->sender('xxx', name)
->from('xxx', name)
->replyTo('xxx' name)
->to('xxx', 'xxx')
->with([
'name' => 'xxx',
'url' => 'xxx',
])
->subject($this->title);
in the blade template of view
$message->embedData($logo, 'logo.png', 'image/png')
at path vendor/symfony/mailer/Transport/RoundRobinTransport.php
it’s workd .when i change like this
it’s seem the $message attachments is an point
the clone can’t clone all
so i change use deep_copy to clone deep for each send
may be the mailgun have change the attachments cid
public function send(RawMessage $message, ?Envelope $envelope = null): ?SentMessage
{
$exception = null;
while ($transport = $this->getNextTransport()) {
try {
$currentMessage = deep_copy($message); //here i change
return $transport->send($currentMessage, Envelope::create($currentMessage)); //here i change
} catch (TransportExceptionInterface $e) {
$exception ??= new TransportException('All transports failed.');
$exception->appendDebug(sprintf("Transport "%s": %sn", $transport, $e->getDebug()));
$this->deadTransports[$transport] = microtime(true);
}
}
throw $exception ?? new TransportException('No transports found.');
}
Rick.Xu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.