I want assist in delivering multiple emails from database using php. I've got a code that actually work , however it are only able to allow 1 email inside it . Can there be a way to change it that helped me to send multiple?


$mail  = new PHPMailer();

//GMAIL config
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->SMTPSecure = "ssl";                 // sets the prefix to the server
    $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
    $mail->Port       = 465;                   // set the SMTP port for the GMAIL server
    $mail->Username   = "******@gmail.com";  // GMAIL username
    $mail->Password   = "785123nick";            // GMAIL password
    $prize = "lol";
//End Gmail

$mail->From       = "from@email.com";
$mail->FromName   = "Jetstar";
$mail->Subject    = "Order Redemption";
$mail->MsgHTML("You have bought  " . $prize . " Print this and collect it at our office.");

    //$mail->AddReplyTo("reply@email.com","reply name");//they answer here, optional
$mail->AddAddress("your-email","name to");
$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {//to see if we return a message or a value bolean
  echo "Mailer Error: " . $mail->ErrorInfo;
} else  echo "Message sent!";

Using phpmailer you might add multiple recipiente simply calling addAddress multiple Occasions.. Check here:


Clearly, as recommended before, you might want to refer to this as script by mean of the cronjob, thus improving limits enforced through the mail server. Bye.


Presuming that you'd like to transmit same email to multiple readers which your emails are saved inside a database, you might make a move such as this:

  1. read emails out of your database table
  2. loop with the emails and pass each current email address to $mail->AddAddress();

By doing this you can include multiple emails for your mail object after which send to any or all.

Hope it will help!