E-mails never arrive, sporadically
Posted: Tue Jan 06, 2009 8:30 pm
Hi, using Swift 3.3.3, sometimes when sending e-mails to a large number of recipients (1500) the class reports no errors, but the e-mails are never delivered. From looking at our router, I know the class is connecting to our Exchange server from our web server, but the e-mails disappear into the ether. Sometimes this code works, sometimes it doesn't.
Separately, I need to customize each outgoing message's contents, but I'm not sure how to do that without a for loop.
My code is,
Separately, I need to customize each outgoing message's contents, but I'm not sure how to do that without a for loop.
My code is,
Code: Select all
<?php
for($n=0; $n<count($subscribersAr); $n++){
print "Send loop ".$n." to ".urldecode($subscribersAr[$n]['email'])."<br>";
// replace keywords
$templateHtml = str_replace('_EMAIL_', urldecode($subscribersAr[$n]['email']), $templateHtml);
try {
// send email
$swift = new Swift($smtp);
$message = new Swift_Message();
$message->setSubject('Happy New Year! January 2009 Newsletter');
$message->attach(new Swift_Message_Part($templateHtml, "text/html"));
$to = new Swift_Address(urldecode($subscribersAr[$n]['email']), urldecode($subscribersAr[$n]['firstName']).' '.urldecode($subscribersAr[$n]['lastName']));
$from = new Swift_Address('news@sierracorporation.com', 'Sierra News');
$swift->to = $to->build();
$swift->from = $from->build();
$swift->send($message, $to, $from);
} catch (Exception $e) {
print_r($e->getMessage());
}
// cleanup
$swift->disconnect();
unset($swift);
unset($message);
unset($sender);
unset($recipient);
}
?>