How to send mail from php scripts without any loss of emails, if not available mail server?

Colleagues, good afternoon.

Please help me in resolving the issue.

There is a site on Bitrix. To send mail use SMTP (via the mail() function of php).
Mail server (Postfix) is in a different place, geographically.
The website and the mail server in the same domain ( and respectively).

The problem is that if the mail server for any reason not available, then a letter, which poisons the website, lost and never gets to the recipient, because ssmtp does not turn and does not re-send.

Prompt, than to replace ssmtp and how to configure?
I understand that you need to put a full-featured MTA, e.g. postfix. It needs to be configured as a relay? In this configuration, whether it is to queue and re-send emails that failed to deliver to the mail server (for example, connection timeout)?
Or maybe there is something simpler?
March 19th 20 at 09:08
2 answers
March 19th 20 at 09:10
Yes, set MTA, it will attempt to send to a successful end (or as customize).
And how to configure the MTA in this case? You need only send from php script from the address + queue. - Lorenzo commented on March 19th 20 at 09:13
@Lorenzo, it all will default in default configuration. Just out relay do not expose. - paxto commented on March 19th 20 at 09:16
@paxto, thank you. I will try. Testovik just is. - Lorenzo commented on March 19th 20 at 09:19
@paxto, Thank you. It worked.
Really have set up postfix through yast. Selected authorization on the mail server, and then in the was commented out
smtp inet n - n - - smtpd

Well, in the tweaked a few settings
delay_warning_time = 0
bounce_queue_lifetime = 7d
maximal_queue_lifetime = 7d
queue_run_delay = 300s
minimal_backoff_time = 300s
maximal_backoff_time = 3600s
address_verify_negative_expire_time = 3d
address_verify_negative_refresh_time = 1h
address_verify_positive_refresh_time = 7d
- Lorenzo commented on March 19th 20 at 09:22
March 19th 20 at 09:12
Don't know, it's easier or not, but all email to queue up, making the entry in the database, you can check the availability of the server (here I don't know exactly how), send email and delete record from database.
Emails sent from Bitrix (he is using the mail() function works). No one will write a separate module. And so, it would not be bad. - Lorenzo commented on March 19th 20 at 09:15
@Lorenzo, and the table b_event isn't this is? - Meggie95 commented on March 19th 20 at 09:18
@Meggie95now pipeline we have, therefore, said that no one would write a module. I myself am only the server admin, in Bitriks does not climb. Therefore, look first at the options how to make at the operating system level and software without interfering with Bitrix.
In the past there were cases when doing a module, and after the update module has stopped working. - Lorenzo commented on March 19th 20 at 09:21

Find more questions by tags MTAPostfixE-mailLinux