Swift mailer class

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
Pugalanthi
Forum Newbie
Posts: 6
Joined: Tue Feb 19, 2008 12:09 am

Swift mailer class

Post by Pugalanthi »

Swift mailer class
Pugalanthi
Forum Newbie
Posts: 6
Joined: Tue Feb 19, 2008 12:09 am

Re: Swift mailer class

Post by Pugalanthi »

Hi

In Swift mailer i want to send batch mailing,
But the subject and body will differ for every receipient.
Please give some idea to do it with swift mailer.

Thak in Advance
Pugalanthi.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Swift mailer class

Post by Zoxive »

User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Re: Swift mailer class

Post by anjanesh »

I guess you'll need to loop it to specify different subject+body.

Code: Select all

$smtp->new Swift_Connection_SMTP("mydomain.com", 25)
$smtp->setUsername("user");
$smtp->setpassword("pass");
 
$swift = new Swift($smtp); 
 
# Not sure if this line has to be in the loop
$swift->attachPlugin(new Swift_Plugin_AntiFlood(100), "anti-flood");
 
$message = new Swift_Message();
$message->setContentType("text/html");
 
for ($i = 0; $i < $Total; $i++)
 {
        $message->setSubject($subject[$i]);
        $message->setBody($body[$i]);
 
        echo $recipient[$i].' : ';
 
        if ($swift->send($message, $recipient[$i], "myname@mydomain.com"))
         echo "Sent";
        else
         echo "Failed";
 
        echo "\n";
 
        # usleep(100);
 }
 
$swift->disconnect();
Last edited by anjanesh on Thu Feb 28, 2008 11:13 am, edited 1 time in total.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Swift mailer class

Post by pickle »

There is a Swift Mailer forum - I've moved this thread there.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply