Re: Non-ascii email subject and header encoding



Hello,

on 03/27/2007 06:55 AM Ciuin said the following:
Hi all,

I need to mail() emails with user input that does contain non-ascii
(umlauts, accents) and non-latin (cyrillic) characters in the
"Subject:" and "From:" headers. I understand that they are typically
encoded in UTF8 like this:

=?UTF-8?B?w5Z0emkg0J/RgNC40LLQtdGC?=

but I cannot find a PHP function to encode the input string in this
way. utf8_encode gives me garbled char soup, so what do you use?

That is binary q-encoding. It is not quoted-printable but it is similar
for message headers. There is a whole RFC on that subject.

Yoy may want to try the MIME message that can be used to compose and
send messages and supports headers with non-ASCII characters encoded as
UTF-8 or any other encoding.

Take a look at the test_multibyte_message.php example script. It
explains how to send messages in Japanese with encoding ISO-2022-JP, but
you can change that for UTF-8 to support characters of all idioms.

http://www.phpclasses.org/mimemessage


--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
.



Relevant Pages

  • Non-ascii email subject and header encoding
    ... I need to mailemails with user input that does contain non-ascii ... and non-latin characters in the ... encoded in UTF8 like this: ... but I cannot find a PHP function to encode the input string in this ...
    (comp.lang.php)
  • Re: Non-ascii email subject and header encoding
    ... I need to mailemails with user input that does contain non-ascii ... and non-latin characters in the ... encoded in UTF8 like this: ... but I cannot find a PHP function to encode the input string in this ...
    (comp.lang.php)
  • Re: Non-ascii email subject and header encoding
    ... I need to mailemails with user input that does contain non-ascii ... and non-latin characters in the ... encoded in UTF8 like this: ... but I cannot find a PHP function to encode the input string in this ...
    (comp.lang.php)
  • Re: urllib.unquote and unicode
    ... input string in unicode is encoded to UTF-8 and then each byte ... followed by two hex characters. ... For all valid URIs ... encode to ascii before unquoting. ...
    (comp.lang.python)
  • Re: HTML entities from input fields
    ... >> IE to encode characters outside of the current code-page ... submitting whatever characters they care to paste into the submission ... Browsers will then send the data in UTF-8 format ...
    (comp.infosystems.www.authoring.html)