I'm using the PHP mail() function to send emails from a Linux server, but using Exchange as the main MTA. To achieve this sendmail has been set up to relay everything to the local Exchange server, which then sends the emails out.
This is working correctly, but the PHP script seems to wait until the timeout limit before finishing. I thought perhaps it's waiting for a response from sendmail, which doesn't come becomes it's just a relay?
I specified the php.ini command line option for "sendmail_path" -odb, which should start sendmail with the "background" delivery mode, meaning to fire off emails in a separate process and then immediately return. But it still takes 30 seconds for the PHP script to end.
Anyone have any ideas? I'm a bit stumped. Thanks.
An indirect solution.
What we do is use php's system() to send emails in the background so the user doesnt have to wait for the email to go out.
something like this...
<?php //sendEmail.php
mail($argv[1], $argv[2], $argv[3]);
?>
your script:
<?php
...
system("php sendEmail.php [email protected] 'subject' 'message' 1>/dev/null 2>&1 &");
...
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With