Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Mime] allow non-ASCII characters in local part of email#36178
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
dmaicher commentedApr 2, 2020
@fabpot seeing that you wrote this component: Any idea from your side about this issue? |
dmaicher commentedApr 14, 2020
@symfony/mergers anyone able to help with this one? |
javiereguiluz commentedMay 3, 2020
@dmaicher Pythonsupports this too via the
And that's the RFC that describes this:https://www.ietf.org/rfc/rfc2047.txt |
dmaicher commentedMay 3, 2020
@javiereguiluz as far as I understand rfc 2047 does not apply for email addresses?
It would only apply for the "name" part of some recipient address header. But not the address itself. |
javiereguiluz commentedMay 3, 2020
@dmaicher I read too fast then. Sorry 😞 |
dmaicher commentedMay 11, 2020
@javiereguiluz any idea how to move this forward? This issue keeps me from using the |
nicolas-grekas commentedJun 30, 2020
I think we can do this change, but only if we also forbid non-ASCII chars in the local part of the envelopesender. The reason is that there always must be a path to receive bounces, and the envelope-sender is their destination. |
dmaicher commentedJun 30, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas first of all thank you for taking to time to look into this! 😊
Not sure I follow this comment. So currently this change should impact the envelope sender as well, right? Seeing that the envelope sender is also an So you mean we should change this behavior for the envelope sender? |
nicolas-grekas commentedJun 30, 2020
We shouldn't necessarily change the behavior of going through the encoder, but we should add a check, in Mailer, to reject any local part with non-ASCII characters. This will ensure that any bounce message will be able to come back to the sender independently of whether SMTP hops are able to deal with UTF-8 or not. This looks like a critical property to me. |
dmaicher commentedJun 30, 2020
Ok fair enough. That seems good to me 👍 How should we do this? Inside |
nicolas-grekas commentedJun 30, 2020
Inside Envelope? this would allow reusing |
Uh oh!
There was an error while loading.Please reload this page.
3f1ee9b to7609bacCompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
dmaicher commentedJul 1, 2020
@fabpot would have been great to see this change in 4.4 LTS... but ok. Why do you think this cannot be treated as a bugfix? Anyway I rebased it 😉 |
fabpot commentedJul 10, 2020
Thank you@dmaicher. |
nicolas-grekas commentedJul 12, 2020
It looks like this broke some tests for bridges, could you please have a look@dmaicher? |
dmaicher commentedJul 12, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas ah sorry I missed those test fails. @fabpot I could simply fix those test fails but not sure the change in behavior is really correct 😕 For example the test fail in $transport =newMandrillApiTransport('KEY',$client);$mail =newEmail();$mail->subject('Hello!') ->to(newAddress('saif.gmati@symfony.com','Saif Eddin')) ->from(newAddress('fabpot@symfony.com','Fabien')) ->text('Hello There!');$message =$transport->send($mail); Now with my changes the name "Fabien" is dropped from the sender address and before it was passed on to Mandrill as EDIT: or maybe the mandrill transport (and others) should not use the sender as "from"? As per RFC the "Sender" can only be an email address without a name as@fabpot mentioned here:#36178 (comment) EDIT: So for example diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.php b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.phpindex 50be4e02cb..027c67cd10 100644--- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.php+++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.php@@ -72,19 +72,25 @@ class MandrillApiTransport extends AbstractApiTransport private function getPayload(Email $email, Envelope $envelope): array {+ $fromAddresses = $email->getFrom();+ $from = reset($fromAddresses);+ $payload = [ 'key' => $this->key, 'message' => [ 'html' => $email->getHtmlBody(), 'text' => $email->getTextBody(), 'subject' => $email->getSubject(),- 'from_email' => $envelope->getSender()->getAddress(), 'to' => $this->getRecipients($email, $envelope), ], ];- if ('' !== $envelope->getSender()->getName()) {- $payload['message']['from_name'] = $envelope->getSender()->getName();+ if ($from) {+ $payload['message']['from_email'] = $from->getAddress();++ if ('' !== $from->getName()) {+ $payload['message']['from_name'] = $from->getName();+ } } foreach ($email->getAttachments() as $attachment) { |
nicolas-grekas commentedJul 12, 2020
Dunno if it helps decide, but this affects deps=high on 4.4 also. |
xabbuh commentedJul 13, 2020
How does Mandrill use the |
dmaicher commentedJul 13, 2020
@xabbuh not sure how Mandrill is handling that but Mailgun seems to use it for the Seehttps://documentation.mailgun.com/en/latest/api-sending.html#sending
And there we also use the envelope sender:https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunApiTransport.php#L94 But that means the "Sender customization feature" usingEnvelopeListener would then not work anymore if we change that? 😕 |
fabpot commentedJul 15, 2020
…sports (fabpot)This PR was merged into the 4.4 branch.Discussion----------[Mime] Keep Sender full address when used by non-SMTP transports| Q | A| ------------- | ---| Branch? | 4.4 <!-- see below -->| Bug fix? | yes| New feature? | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets | n/a <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->| License | MIT| Doc PR | n/arefs#36178The `Envelope` is an SMTP concept. The Sender is used in the `MAIL FROM` SMTP command, where only an address is supported. But we are also supporting non-SMTP transports, where the Sender might also be used as the `From` header, where a full mailbox is supported.To take into account the 2 usages, this PR keeps the full mailbox in the Envelope and let the SMTP class only use the address (which was already the case anyway).Commits-------1ca9be7 [Mime] Keep Sender full address when used by non-SMTP transports
MaSpeng commentedAug 12, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'am sorry but i have to ask, will this "feature" be part of the 5.2 release or will it be an addition to 5.1.4? Another Question is there currently any way to temporarily replace/bypass the\Symfony\Component\Mime\Encoder\IdnAddressEncoder or worse the\Symfony\Component\Mime\Address to create an workaround for this issue? |
javiereguiluz commentedAug 12, 2020
@MaSpeng this was merged as a feature in According to theSymfony Release Process minor versions (e.g. 5.1.4) only contains bug fixes and never new features. So, this will be included only in 5.2 and higher versions, but not in 5.1.*. The good news is thatSymfony 5.2 release is just a few months ago (feature freeze starts in just 6 weeks!) and you can upgrade your app from 5.1 to 5.2 without breaking changes. |
MaSpeng commentedAug 12, 2020
@javiereguiluz Many thanks for the explanations. |
Thisfixes#34932 by allowing non-ASCII characters in the local part of emails.
I tried this using 3 different smtp servers (gmail, mailgun and local postfix) and for me this just works in case there are non-ASCII characters in the local part of emails. Emails are correctly delivered.
PHPMailer does this in the same way:https://github.com/PHPMailer/PHPMailer/blob/master/src/PHPMailer.php#L1411
This is also in line with the behavior of Swiftmailer (< 6.1)before this commit that introduced the
IdnAddressEncoder:swiftmailer/swiftmailer@6a87efd#diff-e5f85d26733017e183b2633ae3c433f0R31I'm not an expert when it comes to SMTP and all the different RFCs out there 😕 But for me this exception seems not needed.
Maybe@c960657 can help here?