Re: mail() in a loop?
- From: The Natural Philosopher <tnp@xxxxxxxxxxxxxxx>
- Date: Sun, 26 Apr 2009 23:09:49 +0100
Daniel wrote:
Hi, Paul,Or exec to a mail program and run it in background..
Yes, you can have mail in the loop;
Personally I would first scan the database, build an array of email addresses and then start sending messages.
Also, sending the bunch of messages from php will be done synchronous, that means that who posted the message will have to wait till the messages are sent and THEN the browser will come back again.
Therefore I would suggest you another approach: try to decouple the process a little bit. Tomorrow you might have 1000 users - create the email messages in the loop, spool them on the hard drive in some folder (you have to do first some housekeeping) and then have a cron job who starts every 5 minutes pick the messages and send them.
Sendmail in fact doesn't send mail..immediately. It queues it. Then forks a process to deliver it.
Regards,.
Daniel
"Paul Fredlein" <paulfredlein@xxxxxxxxxxxxxxx> wrote in message news:1iysc17.1plqfdt117ay0aN%paulfredlein@xxxxxxxxxxxxxxxxxxHi,
I have a simple discussion forum with about 100 members. When a new
topic is posted I would like to email all members to let them know of
the new post.
Can I have mail() in a loop? That is, select all from the mysql database
and loop through sending mail to each one. Any possible problems to look
out for? Should I wait for the mail() function to return before sending
the next? Should I put in a delay or something before sending the next?
Any help appreciated.
Thanks,
Paul
- Follow-Ups:
- Re: mail() in a loop?
- From: Daniel
- Re: mail() in a loop?
- References:
- mail() in a loop?
- From: Paul Fredlein
- mail() in a loop?
- Prev by Date: Re: file_exists strange behavior
- Next by Date: Zend Studio for Eclipse
- Previous by thread: Re: mail() in a loop?
- Next by thread: Re: mail() in a loop?
- Index(es):
Relevant Pages
|
Loading