FAQ
   manual.pipni.com > Mail  |  Search  |  Problems?

How to use mailmerge (ie. newsletter)?
Because of addresses count limits in To and (B)Cc fields, it's necessary (and recommended) to generate for every email address its own mail. (I recommend to use PHPMailer class.)
Short (general) example:
$mail           = new PHPMailer();
$mail->From     = "mailbox@domain.tld";
$mail->Mailer   = "mail";
$mail->CharSet  = "windows-1250"; //for example

$result = query("SELECT email FROM newsletter;");
while ($row = fetch_row($result))
{
  $mail->Body     = $text;
  $mail->Subject  = $subject;
  $mail->AddAddress($row[0]);

  if(!$mail->Send())
    echo "Error sending to " . $row[0] . "<br>";
  else
    echo "OK sending to " . $row[0] . "<br>";

  $mail->ClearAddresses();
}

Total count of tips: 141
Created by PIPNI
Powered by Firebird