Let's assume we have a 2000 email list with newsletter subscribers and we need to mass email them. Servers do have hourly limitations when sending emails to prevent SPAM.
Some have 300 or even 500 emails per hour which is fair enough.
While using swiftmailer throttle plugin to send for example 8 emails per minute (8 * 60 minutes = 480 total mails which is under the 500 limit) server closes the connection and responds with a "404 - Not found page".
The weird thing is that it has sent 100 or less email during script execution but still server treats the procedure as it has fallen to an infinite loop and terminates the script execution.
If I try to send 500 emails at once without the throttle plugin it works like a charm. But what if I need to send more emails like 1500 or 2000?
I've read the the throttle plugin uses PHP's native function sleep()
which should work properly in a situation like this one.
I was informed that it could work if the process is executed through Cron Job and not through the HTTP protocol. I've tried that using wget and curl to set up the cron job but still no luck.
What I've learned from the research I conducted is that when using an SMTP server with Swiftmailer a 3 second process takes 28 seconds (way longer than it should). All queries all optimized and all data are properly placed in memory without overloading the server.
After that I decided to give it a shot without using SMTP but the Throttler Plugin didn't work as it should (again).
Any suggestions or recommendations would be highly appreciated.
EDIT: I've also read this: SwiftMailer Batch email times my Server out
Of course I use this:
ignore_user_abort(true);
set_time_limit(0);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '256M');
ini_set('mysql.connect_timeout', 500);
ini_set('default_socket_timeout', 500);
P.S.: I was forced to change the script's behavior for now so that it calculates the server's limit based on user input for emails per minute and if the total number of active subscribers is LESS OR EQUAL to the emails that are going to be send out, it sends them without the throttle plugin.
Warmest Regards, George Girtsou