Page 1 of 1

problem with phpmailer and double quotes in html body

Posted: Fri Jan 23, 2004 3:57 pm
by vaughajj
I have a form which submits the text body and html body to phpmailer. The email is sent properly except the double quotes are escaped, ie

<a href=\"http://www.jmu.edu/wdc\"> instead of
<a href="http://www.jmu.edu/wdc">

I tried doing a str_replace, but am still having the same problem. Any suggestions? Here is the code:

[syntax=php]<?php

require("../lib/class.phpmailer.php");

$mail = new PHPMailer();

$mail->From = "vaughajj@jmu.edu";
$mail->FromName = "Workforce Development Campus";

$mail->SMTPAuth = true;
$mail->Host = "smtp.jmu.edu";
$mail->Port = "25";
$mail->UserName = "vaughajj";
$mail->Password = "mypassword";
$mail->Mailer = "smtp";


// HTML body (passed through POST as $body)

// Plain text body (passed through POST as $text_body)

$mail->Body = str_replace("\"",'"',$body);
$mail->AltBody = $text_body;
$mail->Subject = $subject;
$mail->AddAddress("vaughajj@jmu.edu");

if(!$mail->Send())
echo "There has been a mail error<br>";

// Clear all addresses and attachments
$mail->ClearAddresses();
?>[/syntax]

Posted: Fri Jan 23, 2004 5:20 pm
by DuFF
You can just run the variable through stripslashes()