Current location: Hot Scripts Forums » Programming Languages » PHP » Help with PHPMailer


Help with PHPMailer

Reply
  #1 (permalink)  
Old 12-06-06, 10:04 PM
lifeway lifeway is offline
New Member
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Help with PHPMailer

for some reason when I add code to my PHPMailer script I only get one variable instead of all of them. I can better explain with an example. Below is an example my PHPMailer code. In bold is the code I've added. For some reason I only get sent the answer for Phone and not Name. If I were to put a third, say for Email, I would only get the Email value. How can I make it so I get all the answers in the body of my email and not just the one?

<?PHP

require("/sites/servername/username/home/includes/class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->Host = "mail.YourDomain.com";
$mail->SMTPAuth = true;
$mail->Username = "you@domain.com";
$mail->Password = "password";

$mail->From = "you@domain.com";
$mail->FromName = "Your Name";
$mail->AddAddress("user@domain.com", "Display Name");

$mail->IsHTML(true);

$mail->Subject = "Test message sent using the PHPMailer component";
$mail->Body = "This is a test message.";
$mail->Body = "Name: ".$_POST['Name']." was the content of the for.";
$mail->Body = "Phone: ".$_POST['Phone']." was the content of the for.";


if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

echo "Message has been sent";
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-07-06, 06:33 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
that's because you're reassigning the value for $mail->Body to "Phone:...."
What you need to do is add a dot before the = sign, like this:
PHP Code:

$mail->Body "Name: ".$_POST['Name']." was the content of the for.";

$mail->Body .= "Phone: ".$_POST['Phone']." was the content of the for."
now you're adding the value "Phone..." to the existing string

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHPMailer help! sejohnson PHP 1 09-19-06 12:00 PM
Sending email to multiple receipients in phpmailer EvilDeveloper PHP 1 02-24-06 09:42 AM
Help please civrob PHP 1 06-03-04 04:54 AM
help wanted in PhpMailer parameswaryn PHP 0 05-06-04 10:30 PM


All times are GMT -5. The time now is 12:05 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.