Re: mail() encoded subject line
| From: | Manuel Lemos | Date: | Mon, 16 Oct 2006 09:29:23 +0000 |
| Subject: | Re: mail() encoded subject line | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-243185@lists.php.net to get a copy of this message | ||
Hello,
on 10/16/2006 02:32 PM Emil Edeholt said the following:
> I hope this is not too off topic but I have a problem when I use mail().
> When I add the header Content-Type: text/plain; charset=UTF-8 the body
> of the mail is encoded fine but the subject is not encoded. I've tried
> to utf8_encode() and utf8_decode() the subject text but neither helps.
>
> Any idea of how to pass what encoding to use on an email subject?
Headers encoding is independent of message body encoding set by
Content-Type. Headers need to be encoded with q-encoding algorithm.
You may want to take a look at this popular MIME message class. Just use
the SetEncodedHeader function to add the Subject or another header that
may use 8 bit (non-ASCII) data.
The character set encoding of the message is set using the
default_charset class variable. But you can use a different character
set encoding for individual headers, using the 3rd parameter of the
SetEncodedHeader function.
Take a look at the test_email_message.php example script that shows how
to send messages with non-ASCII characters in the Subject and body.
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/