开发者

Send an E-mail to an internationalized E-mail address with Python / SMTPlib

开发者 https://www.devze.com 2023-01-18 19:20 出处:网络
In my Python application, I would like to be able to send m开发者_如何学Pythonail to addresses like っていった@example.jp, démo@example.fr, or even عرض@وزارة-الأتصالات.مصر, which

In my Python application, I would like to be able to send m开发者_如何学Pythonail to addresses like っていった@example.jp, démo@example.fr, or even عرض@وزارة-الأتصالات.مصر, which are perfectly valid.

When passing the address as UTF-8, I get an UnicodeDecodeException. If I encode the address with address.encode('utf-8'), no Python error but I get bounce mail explaining Diagnostic-Code: smtp; 501 Malformed RCPT TO: - psmtp.

What's the way to make everything work ?

Thanks.


Make sure the server you're talking to includes UTF8SMTP in its EHLO response. Otherwise it doesn't support rfc5336. You can tell by using telnet or netcat to connect to the server and pretending to be an SMTP client.

0

精彩评论

暂无评论...
验证码 换一张
取 消