Description
Symfony version(s) affected: 4.3.8
Description
With the component Symfony/Mime, it seems not possible to use email address with non ascii characters.
For example, if try to send an email for the address stö[email protected]
or ß[email protected]
the error Non-ASCII characters not supported in local-part os "<email>"
occurs.
How to reproduce
The bug is simple to reproduce. Install with composer the component Symfony/Mailer in your project and copy/paste this code below :
<?php
require_once __DIR__.'/vendor/autoload.php';
use Symfony\Component\Mime\Email;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
$email = (new Email())
->from('[email protected]')
->to('Stö[email protected]')
->subject('Time for Symfony Mailer!')
->text('Sending emails is fun again!');
$transport = new EsmtpTransport('localhost');
$mailer = new Mailer($transport);
$mailer->send($email);
Possible Solution
In the class Symfony\Component\Mime\Encoder\IdnAddressEncoder
there are references to the class Utf8AddressEncoder
and the class SmtpUtf8Handler
.
But these classes does not exist into the project Symfony/Mime
but exist into the project Swiftmailer
.
I think we can use some elements of this pull request to fix this problem : https://github.com/swiftmailer/swiftmailer/pull/1056/files
Additional context
None