I have some PHP code that I'm using to send email to a specific e-mail address. However, I'd like to include a couple more e-mail addresses in the PHP for when it sends it. when i tried it showing the following
ERROR:Mailer Error: You must provide at least one recipient email address.
code
include "class.phpmailer.php"; // include the class file name
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
//$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "mail.authsmtp.com";
$mail->Port = "25"; // or 587
$mail->IsHTML(true);
$mail->Username = "xxxxx";
$mail->Password = "xxxxx";
$mail->SetFrom("[email protected]");
$mail->Subject = $sub1;
$mail->Body = $text_mail;
$mail->AddAddress("[email protected];[email protected];[email protected]");
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
echo "Message has been sent";
}
any one guide me how to do it
Change this line
$mail->AddAddress("[email protected];[email protected];[email protected]");
to this:
$mail->AddAddress("[email protected]");
$mail->AddAddress("[email protected]");
$mail->AddAddress("[email protected]");
You can run that function as many times as you like until you've got all the addresses you need.
See Here for more info
It seems that you are miss using the AddAdress
method. You should pass every mail separatly like that :
$mail->AddAddress("[email protected]");
$mail->AddAddress("[email protected]");
$mail->AddAddress("[email protected]");
See PHPMailer AddAddress() for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With