problem with phpmailer and double quotes in html body

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vaughajj
Forum Newbie
Posts: 1
Joined: Fri Jan 23, 2004 3:57 pm

problem with phpmailer and double quotes in html body

Post 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]
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

You can just run the variable through stripslashes()
Post Reply