On 3/7/07, Uri Even-Chen <[EMAIL PROTECTED]> wrote:

Hi people,

I wrote a PHP program that sends E-mail to 121 E-mail addresses at
once [http://www.speedy.net/knesset/].  The problem is, it takes many
seconds until the program completes sending all the E-mails.  I want
to give the user an instant feedback, and send E-mails later (after
the HTML output is complete).  How do I do it?  Can I postpone the
mail sending function?  My program calls sendmail 121 times, and I
think that's the only slow part of the program.  The rest is quite
fast.  Can I call sendmail in such a way that PHP will regain control
right away?  Or alternatively, can I run another PHP script in the
background?



PHP can also run from command line, using the /usr/bin/php CLI.

So instead of running the script from the browser you can make it run from a
regular shell where the running time is not much of an issue.

Once you do that you can also run it from cron.

Here we have a mailing list manager in PHP that works this way:
1. The site administrator composes the email in a web interface.
2. The message is inserted into a database
3. Once an hour, a PHP script is ran through cron. It selects all the new
messages from the database and mails them.


Uri.



Sagi

Reply via email to