Re: PHP mail() problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

on 03/20/2007 06:54 AM Delta Storm said the following:
> Hi,
> 
> I'm having problem with character encoding in PHP mail functions.
> 
> CODE:
> $headers.= "Content-Type: text/html; charset=iso-8859-1";
>         $headers .= "MIME-Version: 1.0 ";
>         $headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
>         $headers .="Content-Type: multipart/alternative;
> boundary=0-92766976-1174383938=:29106";
>         $to = "unix_master10@xxxxxxxxx";
>         $subject = $_POST['cat'];
>         $body = $_POST['text'];
>         if (mail($to, $subject, $body, $headers))
>         {
>             echo('<p>Message successfully sent!</p><br /><a
> href="showarticle.php?cid=5&id=3">Povratak</a>');
>         }
>         else
>         {
>             echo('<p>Message delivery failed...</p><br /><a
> href="showarticle.php?cid=5&id=3">Povratak</a>');
>         }
> 
> Im receiving mail as you see using yahoo.com. It all works except it
> doesn't show croatian letters... I also tried with encoding utf-8, same
> thing...
> ČĆŽŠĐ

Several things are wrong.

I think Croatian letters need ISO-8859-2 character set. utf-8 is fine
too. Make sure you use the same encoding as you use for the HTML page
where your form is.

Other than that, you should not use 8bit content transfer encoding when
you have non-ASCII characters in the text.

You should use quoted-printable encoding for the body and q-encoding for
the headers.

You have multiple Content-Type headers. Only one is right. For messages
with HTML, you should use only multipart/alternative. However the body
must enclose both a text/plain and a text/html alternative parts.

This is all a bit complicated to do with a small script like you have.
It is much simpler to use ready to use components to do the hard work of
message assembly for you.

I use this MIME message class. It can handle all you need including
non-ASCII character encoding. Take a look at the
test_simple_html_mail_message.php example script.

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/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux