Problem/Motivation

I cannot send emails to addresses with non-ASCII characters. Sending fails with the following exception (caught in Swift_Transport_AbstractSmtpTransport::doMailTransaction:

Swift_AddressEncoderException: Non-ASCII characters not supported in local-part

I tried enabling SMTPUTF8 support by adding the following to TransportFactory::getTransport:

$transport->setExtensionHandlers(array_merge(
    $transport->getExtensionHandlers(),
    [new Swift_Transport_Esmtp_SmtpUtf8Handler()]
));
$transport->setAddressEncoder(new Swift_AddressEncoder_Utf8AddressEncoder());

That fixes the first error, but now it fails with the following error:

Expected response code 250/251/252 but got code "501", with message "501 Invalid RCPT TO address provided"

I tested with version 2.0.0-beta1.

Steps to reproduce

Send an email to an address with non-ASCII characters. eg. aydıgan@example.com.

Proposed resolution

Remaining tasks

Comments

DieterHolvoet created an issue.

geek-merlin’s picture

This sounds like a support question to the upstream library, or better, StackOverflow.

Did you realize this in the class docs:
"f your outbound SMTP server does not support SMTPUTF8, use Swift_AddressEncoder_IdnAddressEncoder instead."

dieterholvoet’s picture

I saw that, but when using Swift_AddressEncoder_IdnAddressEncoder it throws the following error:

Swift_AddressEncoderException: Non-ASCII characters not supported in local-part in Swift_AddressEncoder_IdnAddressEncoder->encodeString() (line 40 of /home/vagrant/sites/uzleuven/vendor/swiftmailer/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php).
Swift_Mime_Headers_MailboxHeader->createNameAddressStrings() (Line: 303)
Swift_Mime_Headers_MailboxHeader->createMailboxListString() (Line: 246)
Swift_Mime_Headers_MailboxHeader->getFieldBody() (Line: 309)

I think the error I attached in the issue description happened because our email provider, Amazon SES, does not support SMTPUTF8. There doesn't seem to be a way to use non-ASCII characters in the local-part when you email provider does not support SMTPUTF8. Not sure if this is a bug or a misconfiguration of SwiftMailer. If it's a misconfiguration, maybe we could consider changing that in the module, if not it's something for the upstream library.