Skip to content

[Mailer] SmtpTransport not encoding addresses #41651

@dmaicher

Description

@dmaicher

Symfony version(s) affected: 5.3.1 and older

Description
We recently moved from Swiftmailer to the Symfony mailer and we have issues with sending emails to domains that contain non-ASCII characters.

Example: something@öäü.com

Our local postfix receives this email address without any Punycode encoding end gives an error like

> RCPT TO:<something@öäü.com>\n
< 501 5.1.3 Bad recipient address syntax\r\n

I had a look and it seems the Symfony\Component\Mime\Encoder\IdnAddressEncoder is not used in this case to encode the addresses.

The SmtpTransport is just using the raw address: https://github.com/symfony/symfony/blob/5.3/src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php#L199

However the SwiftMailer transport was encoding the address first: https://github.com/swiftmailer/swiftmailer/blob/master/lib/classes/Swift/Transport/AbstractSmtpTransport.php#L383

With Swiftmailer the command looks like:

RCPT TO:<something@xn--4ca9at.com>\n

So I'm wondering: Is there a reason we are not encoding addresses anymore?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions