Page 1 of 1

Swift mailer class

Posted: Thu Feb 28, 2008 4:41 am
by Pugalanthi
Swift mailer class

Re: Swift mailer class

Posted: Thu Feb 28, 2008 4:43 am
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.

Re: Swift mailer class

Posted: Thu Feb 28, 2008 7:52 am
by Zoxive

Re: Swift mailer class

Posted: Thu Feb 28, 2008 9:48 am
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();

Re: Swift mailer class

Posted: Thu Feb 28, 2008 11:05 am
by pickle
There is a Swift Mailer forum - I've moved this thread there.