Skip to content

[Mime] Email address with non-ascii characters not supported #34932

Closed
@ke20

Description

@ke20

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öff@yopmail.com or ßert@yopmail.com 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('hello@example.com')
    ->to('Stöff@yopmail.com')
    ->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

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