Click to See Complete Forum and Search --> : Mail loop dying early
bejitto101
10-08-2007, 06:12 PM
Hi there,
I have a loop run from a mysql database that sends out about 30k emails. The problem is that the loop cuts out early so I only get about 100 emails out. I tried searching the web for similar problems and found out that the mail() function shouldn't be used for large volumes of emails. So I tried to use phpmailer but I still have the same problem. Any ideas whats causing it? I can include the code I'm using if that will be any help.
NogDog
10-08-2007, 08:05 PM
You want to use something like the PEAR Mail_Queue (http://pear.php.net/package/Mail_Queue) package that will put the mail requests into a queue to be run as a background process.
PS: For a ready-made mass-mailing program with a web-based interface, you might want to look at poMMo (http://pommo.org/Main_Page).
NightShift58
10-09-2007, 12:28 AM
For a quick fix, try putting these two at the top of your script:
<?php
set_time_limit(0);
ignore_user_abort(true);
?>
It'll prevent your script from timing out at whatever number of seconds your server has been set to time out.
Webnerd
10-09-2007, 06:49 AM
You may also be hitting a memory limit for the script on the server.
http://us2.php.net/manual/en/ini.core.php#ini.memory-limit
Can you run "top" and watch the status of the script as it is processing?
It also may be a better solution to write a temp file with those emails and use a scheduling or crontab manager to have the script execute on the server instead of through HTTP.
bejitto101
10-11-2007, 02:27 PM
Well, I was running it on a cron job, but then the server crashed and I can't get the crontab to work. Which leads me to this question: I was looking throught the mail_queue thing from pear, but that requires a cron job or something similar to run every so often so it can send out email in batches. Is there anyway to do it without a cron job? If not, would it be possible to get some cron help? Also, what do you mean by running "top"?