|Keep It Simple, Stupid|
Sending a UTF-8 (Unicode) E-mailby monarch (Priest)
|on Jun 18, 2008 at 17:03 UTC||Need Help??|
This is a brief summary of code that I've found to send UTF-8 Unicode e-mails that can be sent through SMTP servers that only support 7-bit encoding.
Creating UTF-8 Formatted E-mail Using MIME::Entity
Many SMTP servers will not permit 8-bit characters. UTF-8 encoding requires 8-bit support because the high bit of the first byte is used to indicate successive bytes forming part of the same character.
Assume you have some text containing unicode. For example:
When creating an e-mail use the "quoted-printable" form of encoding for the data which will correctly encode the UTF-8 characters into 7-bit form. E-mail headers, however, must be encoded in the "MIME-Header" form if they contain any UTF-8 characters (which would often be in the case of foreign language subject headings).
The 7-bit version of the e-mail is obtained using the stringify function.
Sending the Encoded Message Using Net::SMTP
Next, it is a relatively trivial matter of sending the appropriately coded message to a SMTP server (using Net::SMTP):
Update: corrected formatting.