Zippyaus Posted October 10, 2008 Share Posted October 10, 2008 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 Link to comment https://forums.phpfreaks.com/topic/127830-solved-php-mail-addaddress-from-database/ Share on other sites More sharing options...
Zippyaus Posted October 10, 2008 Author Share Posted October 10, 2008 In case anyone else has this drama. Turns out to be simple, just use the source directly from the database. It has only taken me all day to work this out. n00b $mail->AddAddress($regData['Email'][0] , $regData['Name'][0]); Link to comment https://forums.phpfreaks.com/topic/127830-solved-php-mail-addaddress-from-database/#findComment-661789 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.