Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fixes email adresses format in header #31986

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
wants to merge 1 commit into from
Closed

Fixes email adresses format in header #31986

wants to merge 1 commit into from

Conversation

xavismeh
Copy link
Contributor

Q A
Branch? 4.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

In the mailer component, when using Symfony\Component\Mime\NamedAddress instances for FROM/TO with SMTP transport, the headers will be misconfigured ie MAIL FROM:Sender Name<test@test.com> when the header must be MAIL FROM:<test@test.com>.
The corresponding names will be used properly in the DATA section (see https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php#L157)

@fabpot
Copy link
Member

fabpot commented Jun 11, 2019

Can you create a small script that shows the error? In SmtpEnveloper, NamedAddresss are converted to Address instances, so I fail to see how you can get the Sender Name in the SMTP commands (same for recipients).

@xavismeh
Copy link
Contributor Author

xavismeh commented Jun 11, 2019

Hello @fabpot ,

Here is my current code:

<?php
        $email = (new TemplatedEmail())
            ->from(new NamedAddress('sender@test.com', 'Sender'))
            ->to(new NamedAddress('recipient@test.com', 'Recipient'))
            ->subject($subject)
            ->text('Some content');

        $this->mailer->send($email);

The current implementation will result in (DATA is not displayed properly in GH but works fine):

  1. MAIL FROM:<Sender <sender@test.com>>\r\n
  2. RCPT TO:<Recipient <recipient@test.com>>\r\n
  3. DATA:\r\n From: Sender <sender@test.com>\r\n To: Recipient <recipient@test.com>\r\n

The following exception is thrown: Expected response code "250" but got code "553", with message "553 <Sender <sender@test.com> Invalid email address.".

Working behavior is/should be:

  1. MAIL FROM:<sender@test.com>\r\n
  2. RCPT TO:<recipient@test.com>\r\n
  3. DATA:\r\n From: Sender <sender@test.com>\r\n To: Recipient <recipient@test.com>\r\n

Note that this issue has been identified using Amazon SES SMTP transport which internally uses the Symfony\Component\Mailer\Transport\Smtp\SmtpTransport::doSend method.

Last, note that the sender property of the DelayedSmtpEnvelope is null, but $enveloppe->getSender() will resolve a NamedAddress instance on request.

@xabbuh xabbuh added the Mailer label Jun 11, 2019
@xabbuh xabbuh added this to the 4.3 milestone Jun 11, 2019
@fabpot
Copy link
Member

fabpot commented Jun 11, 2019

Are you using the component without any modification? I fail to see how that's possible. I've even created a small script to test it and I'm not able to reproduce your behavior.

@xavismeh
Copy link
Contributor Author

xavismeh commented Jun 11, 2019

No changes at all (just rm/reinstalled vendors to be sure). BTW, the only requirement I have in my composer file is symfony/amazon-mailer using a dsn like the following smtp://$AWS_ACCESS_KEY:$AWS_SECRET_KEY@ses?region=eu-west-1

Composer info:
symfony/amazon-mailer v4.3.1
symfony/mailer v4.3.1
symfony/messenger v4.3.1

@fabpot
Copy link
Member

fabpot commented Jun 11, 2019

Got it now! Working on a fix.

@fabpot
Copy link
Member

fabpot commented Jun 11, 2019

@xavismeh see #31992 for the fix.

@fabpot fabpot closed this Jun 11, 2019
@xavismeh xavismeh deleted the mailer-smtp-transport-headers branch June 11, 2019 11:51
fabpot added a commit that referenced this pull request Jun 12, 2019
This PR was merged into the 4.3 branch.

Discussion
----------

Fix sender/recipients in SMTP Envelope

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #31986
| License       | MIT
| Doc PR        | n/a

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against branch 4.4.
 - Legacy code removals go to the master branch.
-->

Commits
-------

7a2f9bf fixed sender/recipients in SMTP Envelope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.