Closed
Description
Symfony version(s) affected
6.4.3
Description
When I use DkimSigner to sign an email and send it, the web profiler's "Emails" page fails to load.
How to reproduce
- create a
new TemplatedEmail()
- sign the email using DkimSigner
- send the signed email
- open the web profiler for the request
- access the "Emails" page
- a Twig RuntimeError is thrown:
Neither the property "getFrom" nor one of the methods "getFrom()", "getgetFrom()"/"isgetFrom()"/"hasgetFrom()" or "__call()" exist and have public access in class "Symfony\Component\Mime\Message".
Example mail-sending code:
$email = (new TemplatedEmail())
->from(new Address('sender@example.com', 'Sender Name'))
->to('recipient@example.com')
->subject('My Subject')
;
$viewParams = [
'foo' => 'bar',
'baz' => 'quux',
];
$text = $this->render('email.txt.twig',$viewParams)->getContent();
$html = $this->render('email.html.twig',$viewParams)->getContent();
$email->text($text);
$email->html($html);
// I am not using TemplatedEmail's textTemplate() and htmlTemplate() methods because it breaks signing - see https://github.com/symfony/symfony/issues/42407
$signer = new DkimSigner(pk:'file:///path/to/dkim/key/dkim.key', domainName:'example.com', selector:'sf');
$signedEmail = $signer->sign($email);
$mailer->send($signedEmail);
If I use $mailer->send($email);
instead (i.e. send the original unsigned email) then the email details show correctly in the Web Profiler.
Possible Solution
No response
Additional Context
No response