8000 Web profiler "Emails" tab breaks with signed emails · Issue #53928 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Web profiler "Emails" tab breaks with signed emails #53928

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

Closed
jontjs opened this issue Feb 13, 2024 · 3 comments
Closed

Web profiler "Emails" tab breaks with signed emails #53928

jontjs opened this issue Feb 13, 2024 · 3 comments

Comments

@jontjs
Copy link
Contributor
jontjs commented Feb 13, 2024

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

  1. create a new TemplatedEmail()
  2. sign the email using DkimSigner
  3. send the signed email
  4. open the web profiler for the request
  5. access the "Emails" page
  6. 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

@HypeMC
Copy link
Contributor
HypeMC commented Feb 14, 2024

@jontjs Hi, could you see if #53934 fixes your issue?

@jontjs
Copy link
Contributor Author
jontjs commented Feb 14, 2024

@HypeMC My project is using SF 6.4, so instead of that pull request, I tried your commit at HypeMC@834167c - that has indeed fixed it.

nicolas-grekas added a commit that referenced this issue Feb 14, 2024
This PR was merged into the 5.4 branch.

Discussion
----------

[Mailer] Fix signed emails breaking the profiler

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #53928
| License       | MIT

Commits
-------

b202d65 [Mailer] Fix signed emails breaking the profiler
@jontjs
Copy link
Contributor Author
jontjs commented Feb 16, 2024

Thanks @HypeMC and @nicolas-grekas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0