What exactly happens after PHP mail function is executed?

Need help with a Linux question. What exactly happens after PHP mail function is executed? Let's say I sent out 10,000 emails in a for loop. The script finished executing. What now takes control for actually sending emails out? Are they scheduled / cached somewhere? (As I understand email is not sent instantly by these large numbers).

2 Replies

It runs the program defined in sendmail_path to submit the message for delivery. Even if you are running something like Postfix or qmail as the mail transfer agent (MTA) on your server, it will provide a suitable program (probably named "sendmail") to perform this function. Once the message is submitted, it will be queued for delivery by your MTA.

Note that it may be inefficient to send a large number of messages in a loop using mail() - PHP recommends looking at some alternatives for this purpose.

https://github.com/php/php-src/blob/128 … ail.c#L101">https://github.com/php/php-src/blob/128eda843f7dff487fff529a384fee3c5494e0f6/ext/standard/mail.c#L101

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct