phpmailer & en asunto entrando como &

I am sending emails using PHPMailer and through my gmail account with SMTP. It all works except when there is an & in the subject, then in my inbox the subject has &

Any way to make this not happen? I've tried setting the charset and encoding the subject.

Mi codigo esta abajo

$mail             = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->CharSet = 'UTF-8';
$mail->SMTPDebug  = false;
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "tls";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 587;                   // set the SMTP port for the GMAIL server
$mail->Username   = "myusername@gmail.com";  // GMAIL username
$mail->Password   = "password";            // GMAIL password
$mail->SetFrom('from@somesite.com', 'From Person');
$mail->AddReplyTo("from@somesite.com", "From Person");
$mail->Subject    = 'An example with a & in the middle';
$mail->MsgHTML('Some text to send');
$mail->AddAddress('myusername@gmail.com');
$mail->Send()

Gracias

preguntado el 03 de mayo de 12 a las 21:05

Looks like a bug in PHPMailer to me. Can you post the raw message itself, as received? -

The subject in the raw format has the & in it. I'm able to look at the message in my sent folder as well and it has the & also. -

1 Respuestas

Try using this code, let me know if it helps.

$mail->Subject    = "=?UTF-8?B?".base64_encode($_POST['subject'])."?=";

Respondido 18 Oct 13, 14:10

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.