[SOLVED] Using Swiftmailer to send bulk messages with CRON
Posted: Thu May 31, 2007 10:34 pm
Hi everyone. I'm new to swiftmailer and trying to wrap my head around some things... I was hoping you all can shed some light on some things... Sorry for the long email. I want to give some background then I have some Qs at the end.
My site offers a service that sends out brief text only (opted-in) emails to users many times throughout the day. The number of messages going out with each blast can range anywhere from 1 to 2000+ (currently), but will be growing with time. Right now mail is being sent successfully since we are smaller, but as we grow I want to ensure the server can handle the load and prevent crashes.
I just came across SwfitMailer and am blown away. I wish I had found it earlier. I'm going to be implementing it this weekend.
I should mention the server is a Dedicated Virtual Server w/ 512 MB Ram. The Box has PHP4, Linux (CentOS) and Plesk on it. (and only 1 domain currently running on it)
With all the research I've been doing this week. I've had a few questions I could use help with:
1. I read on this forum that a good option for bulk mailing would be to use SwiftMailer along with CRON to disperse the load. I get the concept but I'm unsure of the proper technique. Would I write all messages to a DB queue and run cron ever X minutes to send X messages out. Or is there another method to track what messages were sent and what needs to still go out?
2. I'm currently processing the php script and sending the mail on the same server (via QMAILs MTA). I'm on a dedicated Virtual Server right now. Seems to be running well, but I have had a few moments of panic when the web server suspended actions. Not sure why exactly... we don't have a huge amount of traffic. I'd like to take advantage of Swiftmailers ability to distrubute the sends out to several servers. Since we only have the one
server now, I'm not exactly sure what other servers I can use. Can anyone recommend any services that we can connect to?
3. I was trying an SMTP test with Swiftmail. I had success sending via the following SMTP test:
and with
When sending either way, it went out successfully, though I thought it would fail without authentication. Sending mail fails when I try to send mail from my mail app on my computer without authentication. Is that odd? Is it because the script and server are on the same machine?
4. I tried sending a simple test send via Sendmail using the following code:
I continually get the following error:
Warning: Invalid argument supplied for foreach() in /var/www/vhosts/domain.com/subdomains/dev/httpdocs/util/lib/swift/Swift/Connection/Sendmail.php on line 323t
I also tried both of these lines and received the same error
or
Also, side question... should I force it to qmail. Is there a benefit? Is it possible?
5. Would sending w/ Swift_Connection_Rotator via SMTP and sendmail on the same machine as the script help me at all? I assume no.
I realize this is a long email. But i'm about to head into some new stuff I've never done before. Any feedback would really help me out.
Thanks for reading this far
Fish
><>
My site offers a service that sends out brief text only (opted-in) emails to users many times throughout the day. The number of messages going out with each blast can range anywhere from 1 to 2000+ (currently), but will be growing with time. Right now mail is being sent successfully since we are smaller, but as we grow I want to ensure the server can handle the load and prevent crashes.
I just came across SwfitMailer and am blown away. I wish I had found it earlier. I'm going to be implementing it this weekend.
I should mention the server is a Dedicated Virtual Server w/ 512 MB Ram. The Box has PHP4, Linux (CentOS) and Plesk on it. (and only 1 domain currently running on it)
With all the research I've been doing this week. I've had a few questions I could use help with:
1. I read on this forum that a good option for bulk mailing would be to use SwiftMailer along with CRON to disperse the load. I get the concept but I'm unsure of the proper technique. Would I write all messages to a DB queue and run cron ever X minutes to send X messages out. Or is there another method to track what messages were sent and what needs to still go out?
2. I'm currently processing the php script and sending the mail on the same server (via QMAILs MTA). I'm on a dedicated Virtual Server right now. Seems to be running well, but I have had a few moments of panic when the web server suspended actions. Not sure why exactly... we don't have a huge amount of traffic. I'd like to take advantage of Swiftmailers ability to distrubute the sends out to several servers. Since we only have the one
server now, I'm not exactly sure what other servers I can use. Can anyone recommend any services that we can connect to?
3. I was trying an SMTP test with Swiftmail. I had success sending via the following SMTP test:
Code: Select all
$swift =& new Swift(new Swift_Connection_SMTP("localhost"));Code: Select all
$swift =& new Swift(new Swift_Connection_SMTP("mail.mydomain.com"));4. I tried sending a simple test send via Sendmail using the following code:
Code: Select all
require_once $_SERVER['DOCUMENT_ROOT'] . "/util/lib/swift/Swift.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/util/lib/swift/Swift/Connection/Sendmail.php";
$swift =& new Swift(new Swift_Connection_Sendmail());
$message =& new Swift_Message("My subject", "My body");
if ($swift->send($message, "email@somedomain.com", "me@mydomain.com")) echo "Sent";
else echo "Failed";Warning: Invalid argument supplied for foreach() in /var/www/vhosts/domain.com/subdomains/dev/httpdocs/util/lib/swift/Swift/Connection/Sendmail.php on line 323t
I also tried both of these lines and received the same error
Code: Select all
$swift =& new Swift(new Swift_Connection_Sendmail(SWIFT_SENDMAIL_AUTO_DETECT));Code: Select all
$swift =& new Swift(new Swift_Connection_Sendmail("/usr/sbin/sendmail -bs"));5. Would sending w/ Swift_Connection_Rotator via SMTP and sendmail on the same machine as the script help me at all? I assume no.
I realize this is a long email. But i'm about to head into some new stuff I've never done before. Any feedback would really help me out.
Thanks for reading this far
Fish
><>