Page 1 of 1

Sending many emails

Posted: Thu Dec 28, 2006 2:44 pm
by shiznatix
I looked through the docs and the topics here and came up short. I want to send like 1000 emails (a newsletter) but my mail server can only take so much of course. How can I do this without loading all the people into 1 huge array and having swift just try to mail them all out at once?

Posted: Thu Dec 28, 2006 2:53 pm
by John Cartwright
foreach(), swift mailer, and swift mailers anti-flood plugin :wink:

Posted: Fri Dec 29, 2006 8:40 am
by shiznatix
Ok so I dont quite know how to use the anti flood plugin. This is my code as I think it should work:

Code: Select all

require('Swift/Swift.php');
require('Swift/Swift/Connection/SMTP.php');
require_once 'Swift/Swift/Plugin/AntiFlood.php';

$swift = new Swift(new Swift_Connection_SMTP('mail.mediapostinc.com'));

$swift->loadPlugin(new Swift_Plugin_AntiFlood);

if (!$swift->hasFailed())
{
    $swift->addPart($NewsLetter['HTML'], 'text/html');

    //Pass the array to send()
    $swift->send(
        $Emails,
        '"MediaPostInc" <MediaPostInc@mediapostinc.com>',
        'Media Post Inc Newsletter'
    );
    $swift->close();
}
this works for sending email to only 2 recipients but I dont have a list of 100 to test it on so I want to make sure it will work before i even try to send to our real email list.

Posted: Fri Dec 29, 2006 9:03 am
by Chris Corbyn
That's correct. You'll probably want to pass some values to the constructor of Swift_Plugin_AntiFlood to get expected behaviour but what you're doing will work :)