Sending many emails

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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Sending many emails

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

foreach(), swift mailer, and swift mailers anti-flood plugin :wink:
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :)
Post Reply