|
Posted by Roger Dodger on 11/18/71 11:43
I have to send out 2500 e-mails to student survey recipients. The
e-mails will appear to come from the specific departments that they
belong to. I'm utilizing PHPmailer in the scripts I wrote to
accomplish this. I've written several pages to edit emails utilizing
placeholders so each individual email can be personalized for the
recipient, and selection page to choose recipients from the database.
The code I've written works just fine for small batches, but I'm unable
to test the mass mail as I don't have a suitable test list of email
addresses. I've adjusted the max_execution_time in the php.ini to 300
seconds, which should probably be long enough to send them all. I'll
start off sending in small batches, but eventually will want to just
send them out all at once for future mailings. Can you look at the
code below and suggest any other timeout issues that might appear?
Thanks all.
require("class.phpmailer.php");
require("dbconn.php");
session_start();
$mail = new PHPMailer();
$mail->Subject = $_SESSION['subject'];
$mail->Host = "smtp.*******.edu";
$mail->Mailer = "smtp";
$mail->AddBCC($_SESSION['bcc'],"SURVEY BCC");
$mail->SMTPKeepAlive = true;
$enabled_only = true;
$rs = getRecips($conn, $enabled_only); //Record set contains recipient
data
$i=0;
foreach ($rs as $row) {
$mail->From = $row['DEPT_CONTACT_EMAIL'];
$mail->FromName = $row['DEPT_CONTACT'];
$mail->AddReplyTo($row['DEPT_CONTACT_EMAIL'],$row['DEPT_CONTACT']);
// HTML body
$body = processHtmlBody($_SESSION['body'], $row, true);
// Plain text body (for mail clients that cannot read HTML)
$text_body = processTextBody($_SESSION['body'], $row, true);
$mail->Body = $body;
$mail->AltBody = $text_body;
$fullname = $row['FIRST_NAME']." ".$row['LAST_NAME'];
$mail->AddAddress($row['EMAIL'], $fullname);
if(!$mail->Send()) {
$_SESSION['send_result'][$i] = "Mail error sending to " .
$row['EMAIL'] . "<br />\nError Message: ".$mail->ErrorInfo."<br />\n";
}
else {
$_SESSION['send_result'][$i] = "Mail sent to ".$row['EMAIL']."
from department: ".$row['DEPT_NAME']."<br />\n";
}
$i++;
// Clear all addresses and reply-tos for next loop
$mail->ClearAddresses();
$mail->ClearReplyTos();
}
$mail->SmtpClose();
clearRecips($conn);
header("location: http://localhost:8080/phpmailer/mailresult.php");
Navigation:
[Reply to this message]
|