xpepermint / smtp-client

Simple, promisified, protocol-based SMTP client for Node.js.
36 stars 13 forks source link

Add support for UTF8 senders/recipients #7

Closed ARitz-Cracker closed 3 years ago

ARitz-Cracker commented 3 years ago

If the sender or receiver has utf8 characters in their address, then the MAIL command must end with SMTPUTF8. (if the server supports it) Otherwise, the server will complain when it receives 8 bit data.

Since this library has no knowledge of the recipients when it sends the MAIL command (which is fair since this is a "low level" library anyway) we have no way of knowing whether or not we even need to enable SMTPUTF8 extensions. So that responsibility can fall on the people who end up using this thing.

xpepermint commented 3 years ago

Not sure if that covers all cases but it's a good workaround for now. Thanks for the PR.

xpepermint commented 3 years ago

v0.3.3

ARitz-Cracker commented 3 years ago

Thank you for accepting the PR!

This should work in most cases, as the leftmost part of the email address before the @ is only useful information to the destination server. If the destination server doesn't support unicode users, then it definitely won't have a unicode-named mailbox. However, I found that the domain part should always be punycoded. I use the punycode package's toASCII function for that Some mail server software, even if they're utf8 aware, won't escape the domain themselves before looking up the domain.

(E-mail is such a pain)