Problem sending emails to several recipients?

All you need to do is break the job into manageable chunks, instead of reading in all 50,000 emails and trying to send them all Read in only X emails from the database at a time Send that batch of X emails individually (If X = 10 you will send 10 separate emails) Mark each email as "sent" as soon as each email is sent, otherwise, if there is an error, you may want to increment "send attempts" on that particular email After the X emails have been sent (or attempted), update your statistics to indicate that X emails have been sent Go back to 1 I suggest starting with X = 1.

All you need to do is break the job into manageable chunks, instead of reading in all 50,000 emails and trying to send them all. Read in only X emails from the database at a time. Send that batch of X emails individually (If X = 10, you will send 10 separate emails).

Mark each email as "sent" as soon as each email is sent, otherwise, if there is an error, you may want to increment "send attempts" on that particular email. After the X emails have been sent (or attempted), update your statistics to indicate that X emails have been sent. Go back to 1.

I suggest starting with X = 1.

I did this by making a script that calls itself with the id of the user it last processed. E.g. Sendmail.

Php will then call sendmail. Php? Id=1 which will then call sendmail.

Php? Id=2 and so on. That will fix your timeout issue.

Within the script you can echo out the results of the mail command. If its false, then you could echo out an error. I also added a field in my user table for mail send date and time, so I could have a confirmation of where the script got to incase the browser died.

Your sql for getting the next user to send email to would then be something along the lines of Select useremail from users where sendmaildatetime is not null limit 1 Assuming your default for the sendmaildatetime column is null. Sorry if im not detailed enough, im writing this from my iphone and its a PITA :).

Hamlin11 response is right, if you want to manage such a big email sending you MUST do it in small chunks and manage this task as an asynchronous task. To Manage asynchronous tasks you'll have a lot of way, a subprocess check on all your requests that some async jobs are waiting, a separate cron job, a call on a cron. Php script from a crontab, even psynnott answer, with an external script relaunching himself at the end.

But you could also use the right tool for the right task, if you have some control on the system under your website. Send one simple email to a mailing list manager that would do the job for you. This would only imply you create the right user list in the mailing list manager.

External mailing list manager are for example mailman or sympa. These tools contains robots that you can talk with to feed mailing list recipients. @psynnott answer can be seen as an external PHP script performing very simple mailing list manager tasks.

If you want to alter content of the email depending on some user parameters you'll quite certainly have to write your own separate process managing the tasks. But you could also search for web services handling this job for you. Spam management is a hard job and managing an official big mailer is an hard job as well, but this is not free, of course.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions