| Linode Forum https://forum.linode.com/ |
|
| php utf-8 emails with national characters https://forum.linode.com/viewtopic.php?f=11&t=9235 |
Page 1 of 1 |
| Author: | dubi [ Mon Aug 06, 2012 6:16 pm ] |
| Post subject: | php utf-8 emails with national characters |
I'm facing an interesting issue and am not sure where to look for the solution. Here are the details: (1) php code is used to send an html message. (2) the message contains Hebrew characters. (3) when the message is received at the other end (a gmail account) by an auto parser, all the Hebrew characters appear as question marks and the parser fails. (4) when the message is sent to any other destination (also gmail), being opened and then forwarded to the parser, the Hebrew chars are correctly received and parsed. (5) when the message is auto-forwarded from other email accounts to the parser, the Hebrew chars appear as question marks again. Relevant part of the PHP code: Code: $headers = "From: $from\r\n"; as per RFC 1555: http://www.ietf.org/rfc/rfc1555.txt Have tried also the following headers: Code: $headers = "From: $from\r\n"; and also with the following conversion: Code: mail($to, $subject, iconv("UTF-8", "ISO-8859-8//TRANSLIT", $message), $headers);any idea would be great !! cheers !! |
|
| Author: | Vance [ Tue Aug 07, 2012 12:13 am ] |
| Post subject: | Re: php utf-8 emails with national characters |
Assuming you don't need to deal with Hebrew characters in the source/destination addresses or the Subject: line, you should be able to handle everything within the HTML document ($message). It's not a surprise that some mailservers don't handle your first example well; it's missing some MIME headers. Try including all the relevant ones: Code: $headers = "From: $from\r\n"; Note that the 8bit transfer encoding is specified. This will keep the non-ASCII characters from being munged. If the path the mail traverses over the Internet is not 8-bit clean, the mailservers should be able to automatically convert the body to quoted-printable or base64. If this doesn't work, you could wrap a call to quoted_printable_encode() around $message and use Content-Transfer-Encoding: quoted-printable\r\n instead. In the HTML $message, it would be a good idea to include a line Code: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> in the head section. This tells the parser what character set to expect, since the file may already be separated from the mail headers. |
|
| Author: | dubi [ Tue Aug 07, 2012 3:23 pm ] |
| Post subject: | Re: php utf-8 emails with national characters |
@Vance - Thank you so much. Your fixed headers did the trick! Cheers!!! |
|
| Page 1 of 1 | All times are UTC-04:00 |
| Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |
|