mameha Posted March 26, 2007 Share Posted March 26, 2007 I have a multi language website. Sometimes users send messages to us via the online contact form. This uses the mail() function in PHP. The problem is, when chinese or korean is in the subject, the from and subject data is lost. Actually it is fine in gmail, yahoo mail, thunderbird and everyones email client except my companies local email client (Eudora, japanese version). So for everyone else it is ok, only us here get the lost data. I dont know if this is caused by our homemade anti-spam program or Eudora or something else. The systems guy said its a bug in my code, which is think is dubious. Something about the MIME type not being set correctly etc. This is my code to send email: $emailTo = '[email protected]'; $emailSubject = clean($_POST['subject']); $emailMessage = clean($_POST['msg']); $from = "[email protected]"; $headers .= 'From: ' . $from . "\r\n"; $headers .= 'Cc: ' . $emailCC . "\r\n"; $headers .= 'Bcc: ' . $emailBCC . "\r\n"; $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/plain; charset=utf-8\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $emailed = mail($emailTo, $emailSubject, $emailMessage, $headers); ... Is there something wrong with that? Link to comment https://forums.phpfreaks.com/topic/44309-mail-and-mime-problem/ Share on other sites More sharing options...
Wuhtzu Posted March 26, 2007 Share Posted March 26, 2007 I think it maybe has something to do with this: Encoded-Word Since RFC 2822, message header names and values are always ASCII characters; values that contain non-ASCII data must use the MIME encoded-word syntax (RFC 2047) instead of a literal string. This syntax uses a string of ASCII characters indicating both the original character encoding (the "charset") and the content-transfer-encoding used to map the bytes of the charset into ASCII characters. The form is: "=?charset?encoding?encoded text?=". * charset may be any character set registered with IANA. Typically it would be the same charset as the message body. * encoding can be either "Q" denoting Q-encoding that is similar to the quoted-printable encoding, or "B" denoting base64 encoding. * encoded text is the Q-encoded or base64-encoded text. Difference between Q-encoding and quoted-printable The ASCII codes for the question mark (?) and equals sign may not be represented directly as they are used to delimit the encoded-word. The ASCII code for space may not be represented directly because it could cause older parsers to split up the encoded word undesirably. To make the encoding smaller and easier to read the underscore is used to represent the ASCII code for space creating the side effect that underscore cannot be represented directly. Use of encoded words in certain parts of headers imposes further restrictions on which characters may be represented directly. For example, Subject: =?utf-8?Q?=C2=A1Hola,_se=C3=B1or!?= is interpreted as "Subject: ¡Hola, señor!". The encoded-word format is not used for the names of the headers (for example Subject). These header names are always in English in the raw message. When viewing a message with a non-English e-mail client, the header names are usually translated by the client. It's quoted from http://en.wikipedia.org/wiki/MIME and hopefully it gets you in the right direction Wuhtzu Link to comment https://forums.phpfreaks.com/topic/44309-mail-and-mime-problem/#findComment-215248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.