LLeoun Posted October 2, 2009 Share Posted October 2, 2009 Hi all, I'm using php mail this way: <?php $to = "[email protected]"; $subject = "Subject with á é í ó ú or ñ characters"; $body = "Here the body text with á é í ó ú or ñ characters working fine"; $headers = "From: [email protected]\r\nReply-To: [email protected]"; if (mail($to, $subject, $body, $headers)) { echo("<p>Thanks! message sent</p>"); } else { echo("<p>Error...</p>"); } ?> With it, I'm receiving an email with the correct body but with "Subject with X X X X X or X characters" in the subject. I've tried adding $header .= "Content-Type: text/plain; charset=ISO-8859-1"; or $header .= "Content-Type: text/html; charset=UTF-8"; but is not working What can I do to have the proper subject?? Thanks a lot! PD: sorry not to enclose the mail code in between code tags, the preview was showing the accented characters in ASCII code. Link to comment https://forums.phpfreaks.com/topic/176264-spanish-characters-appearing-as-x-in-mail-subject/ Share on other sites More sharing options...
Bricktop Posted October 2, 2009 Share Posted October 2, 2009 Hi Leounn, I think you will need to specify an encoding type using the $headers variable, i.e.: $headers .= "Content-type: text/plain; charset=UTF-8\r\n"; $headers .= "Content-Transfer-Encoding: 7bit\r\n"; $headers = "From: [email protected]\r\nReply-To: [email protected]"; Hope this helps. Link to comment https://forums.phpfreaks.com/topic/176264-spanish-characters-appearing-as-x-in-mail-subject/#findComment-928956 Share on other sites More sharing options...
LLeoun Posted October 2, 2009 Author Share Posted October 2, 2009 thanks Bricktop, but I'm afraind I still have the Xs in the subject Link to comment https://forums.phpfreaks.com/topic/176264-spanish-characters-appearing-as-x-in-mail-subject/#findComment-928958 Share on other sites More sharing options...
Bricktop Posted October 2, 2009 Share Posted October 2, 2009 Hmm, give the following a try: $headers = "Content-type: text/plain; charset=iso-8859-15\r\n"; $headers = "Content-Transfer-Encoding: 7bit\r\n"; $headers = "From: [email protected]\r\nReply-To: [email protected]"; Or, try the utf8_decode() function on the subject line, e.g.: if (mail($to, utf8_decode($subject), $body, $headers)) { Hope this helps. Link to comment https://forums.phpfreaks.com/topic/176264-spanish-characters-appearing-as-x-in-mail-subject/#findComment-928962 Share on other sites More sharing options...
LLeoun Posted October 2, 2009 Author Share Posted October 2, 2009 Found the solution: $subject = iconv_mime_encode('Subject',$subject); Thanks a lot Bricktop, you gave me the hint ! Link to comment https://forums.phpfreaks.com/topic/176264-spanish-characters-appearing-as-x-in-mail-subject/#findComment-928978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.