Jump to content

[SOLVED] PHP Mail - AddAddress from Database


Zippyaus

Recommended Posts

Hi all

 

I would like to get the AddAddress to include the variables for FullName and Email, which is retrieved from my database, to complete the to address.

 

If I manually enter the address the form works perfectly, but as soon as I try to get the email address and name it does not work.

 

The Name is working fine in other parts of the email message.

 

//error_reporting(E_ALL);
error_reporting(E_STRICT);

date_default_timezone_set("Australia/Perth");
//date_default_timezone_set(date_default_timezone_get());

include_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();

$FullName         = $regData['Name'][0];
$EmailID         = $regData['Email'][0];

$body             =  $FullName. " has joined the challenge.<br>." ;
$body             = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "my.smpt.com"; // SMTP server

$mail->From       = "[email protected]";
$mail->FromName   = "Zippy Aus";

$mail->Subject    =  $FullName. " has joined the challenge";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$mail->AddAddress($EmailID. , $FullName.);
//$mail->AddAddress("[email protected]", "Joe Blogs");

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
  echo $FullName;
echo $EmailID;

}

 

 

I have the echo statements at the end and if the mail sends successfully these show the correct data.

 

Am I doing something wrong by using the .$code ??

 

Any help would be greatly appreciated.

 

Cheers

 

ZP

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.