E-mails never arrive, sporadically

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
jamchild
Forum Newbie
Posts: 3
Joined: Tue Jan 06, 2009 8:18 pm

E-mails never arrive, sporadically

Post by jamchild »

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,

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);
    
}
?>
 
jamchild
Forum Newbie
Posts: 3
Joined: Tue Jan 06, 2009 8:18 pm

Re: E-mails never arrive, sporadically

Post by jamchild »

Any ideas on this? I could really use some help. :banghead:
Post Reply