Simply configure your MTA to queue requests coming from PHP.  Your php.ini
file has the sendmail invocation line that is used by PHP's mail()
function.  Most MTA's out there have a sendmail-like interface and most
have a way to tell it to simply queue the request and return immediately.

For sendmail you tell it to queue by adding a option to the command line
specified in php.ini using the -o flag.  Check your sendmail docs for the
actual option, but on my system my docs say:

    Set  the  delivery mode to x.  Delivery modes are `i' for
    interactive (synchronous) delivery, `b' for background
    (asynchronous) delivery, `q' for queue only - i.e., actual
    delivery is done the next time the queue is run,  and
    `d'  for  deferred - the same as `q' except that database
    lookups for maps which have set the -D option (default
    for the host map) are avoided.

Don't forget that if you just queue the mssages, you need to flush the
queue every now and then.  Traditionally that is done by a cron job that
runs periodically and calls sendmail to flush the queue.


On Wed, 21 Aug 2002, Pupeno wrote:

> I know this issue have been discussed a lot of times but I checked a lot of
> archives and documents and I couldn't find any solution.
> What I want to do is send a lot of mails (belive me, it's not spamming) and
> I thought about running the process of sending mails in background
> (detached from the PHP script that runs it), so the page will return
> immediatly and the other process will continue sending the mails in the
> background.
> I didn't find any way to run a process in the background from PHP
> succesfully.
> The manual says that using system(), if the stdout is redirected to a file,
> it's run in background, I tryed redirecting stdout, stderr and stdin
> to/from files and it still waits for the termination of the process, I
> tryed adding & at the end of the process line and it didn't work neither.
> Any idea of how I can do this (without using at, but maybe cron, I don't
> know how) ?
> Thank you.
> --
> PHP General Mailing List (
> To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to