Open golonix opened 5 years ago
This is still an issue. @golonix did you find a way to handle this in Laravel?
@danielbehrendt yes, I have a workaround for this. You need to redefine some of the dependencies in Swift DI container.
In your AppServiceProvider::boot()
(or in fact in any registered SP, but in the boot
method), put:
\Swift_DependencyContainer::getInstance()
->register('transport.smtp')
->asNewInstanceOf('Swift_Transport_EsmtpTransport')
->withDependencies([
'transport.buffer',
'transport.smtphandlers',
'transport.eventdispatcher',
'transport.localdomain',
'address.utf8addressencoder', // this is changed in relation to original definition
])
->register('transport.smtphandlers')
->asArray()
->withDependencies([
'transport.authhandler',
'transport.smtputf8handler', // this is added in relation to original definition
])
->register('mime.headerfactory')
->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory')
->withDependencies([
'mime.qpheaderencoder',
'mime.rfc2231encoder',
'email.validator',
'properties.charset',
'address.utf8addressencoder', // this is changed in relation to original definition
]);
With this you will be able to send a message to an email with non-ascii chars in the local part of the address, for example: Dörte@Sörensen.example.com
.
But again, this is a workaround (maybe even not the best), not a solution for the problem. However, I hope it helps, at least for the time being.
Currently, there is a problem with sending emails to addresses that contains non-ascii characters on the local part of an address (before @). The problem exists with SMTP driver. SMTP driver uses
Swift_SmtpTransport
class as an email transport layer. This class's constructor calls parent's constructor and passes arguments that are resolved out of the Switfmailer's dependency container. One of the dependencies is address encoder. By default, it is an IDN address encoder, which allows non-ascii chars only on domain part of an address (after @) and that is causing the issue.Swiftmailer's documentation suggests how to mitigate that issue:
Question is: should we wait and see how Swiftmailer handles that or should we add a bypass and fix that issue on Laravel side until it is resolved in vendor?