Jump to content

Spanish characters appearing as X in mail subject


LLeoun

Recommended Posts

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.

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.