Swift Mailer for sending mass email?
Posted: Wed May 27, 2009 6:52 pm
I was previously sending approx. 1000 emails via mail() function. The PHP manual doesn't recommend using mail in a loop for mass emails so I started looking at other options. I've heard good things about Swift Mailer and decided to try it.
My script was set for five minutes, however it timed out before I got done. I know I can set the script to never time out but this seems no faster (perhaps slower) than using the mail function. So I have a few questions:
Many thanks for reading my post.
UPDATE: I just re-read the documentation. I was using the mail() function after all
Unfortunately, I can't test this until another email notification mass email is sent out.
My new code has:
My script was set for five minutes, however it timed out before I got done. I know I can set the script to never time out but this seems no faster (perhaps slower) than using the mail function. So I have a few questions:
- Does $mailer->send($message) require a status for each time it is called (as opposed to an async call?)
- I'm using sendmail configured as a smarthost. Is there some way I can force the messages to be locally queued (again, an async call that just spits out the message and moves on?)
- Should I not be using Swift Mailer as a mass mailer?
Code: Select all
<?php
require_once 'lib/swift_required.php';
//Create the Transport
$transport = Swift_SendmailTransport::newInstance();
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
$message = new Swift_Message($title);
$message->setFrom(array(
FROM_EMAIL => FROM_EMAIL_NAME
));
$message->setReturnPath(FROM_BOUNCE);
// all this is inside loop for each email user
$message->setBody($body, 'text/html');
$message->setTo(array(
$cols[FIELD_EMAIL] => $recipient_name
));
$mailer->send($message);
// end loop
?>UPDATE: I just re-read the documentation. I was using the mail() function after all
My new code has:
Code: Select all
<?php
//Create the Transport
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
?>