Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Aug 06, 2012 6:16 pm 
Offline
Newbie

Joined: Wed Jul 11, 2012 6:01 am
Posts: 2
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";
$headers .= "Content-type: text/html\r\n";

// $message is an html code with Hebrew content.
mail($to, $subject, $message, $headers);


as per RFC 1555: http://www.ietf.org/rfc/rfc1555.txt
Have tried also the following headers:
Code:
$headers  = "From: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=ISO-8859-8\r\n";
$headers .= "Content-transfer-encoding: BASE64 | Quoted-Printable\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 !!


Top
   
PostPosted: Tue Aug 07, 2012 12:13 am 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
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";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\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.


Top
   
PostPosted: Tue Aug 07, 2012 3:23 pm 
Offline
Newbie

Joined: Wed Jul 11, 2012 6:01 am
Posts: 2
@Vance - Thank you so much. Your fixed headers did the trick! Cheers!!!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group