Delay when using the PHP mail () function to send email through Exchange (using sendmail as a relay)

I use the PHP mail () function to send emails from a Linux server, but using Exchange as the primary MTA. To achieve this, sendmail was configured to send everything to the local Exchange server, which then sends emails.

This works correctly, but the PHP script seems to wait until the timeout ends. I thought that maybe he is waiting for a response from sendmail that does not come, is it just a relay?

I specified the php.ini command-line option for "sendmail_path" -odb, which should start sendmail with the background delivery mode, which means to disable emails in a separate process and return immediately. But it still takes 30 seconds to complete the PHP script.

Does anyone have any idea? I'm a bit stumped. Thanks.

+3
source share
6 answers

Indirect decision.

What we do is use php system () to send emails in the background, so the user does not need to wait until the email comes out.

something like that...

<?php //sendEmail.php
mail($argv[1], $argv[2], $argv[3]);
?>

your script:

<?php
...
system("php sendEmail.php to@address.com 'subject' 'message' 1>/dev/null 2>&1 &");
...
?>
+1
source

, php/mail. PHP MTA ? , PHPMailer, .

postfix ( linux 3 ) , Postfix , , sendmail.

+1

PEAR Mail. qmail Exchange SMTP.

0

-odb ( sendmail 8.7 ). 1
-ODeliveryMode=b ( sendmail sendmail_path)
O DeliveryMode=b PHP mail. 2

0

. 30- . , , , , 30 , -, 30- . , , . , Exchange, , , , . , Wireshark, , Exchange, .

0

If this helps my sendmail_path is as follows:

sendmail_path = /usr/sbin/sendmail -t -i
-1
source

Source: https://habr.com/ru/post/1717642/


All Articles