Ajay_kumar
Ajay_kumar

Reputation: 29

How to get information of mail delivery in PHP

I want to send mail by PHP mail() function.

Does PHP mail() function return delivery status? If not then what is the way to find whether my mail is delivered or not in PHP?

Upvotes: 0

Views: 7502

Answers (3)

bcosca
bcosca

Reputation: 17555

You can check /var/log/mail.log, which is the usual location of the sendmail log and only if sendmail has been configured properly in syslog.conf.

# Log anything of level info or higher.   
* .info;authpriv.none;cron.none
# Log all the mail messages in one place.  
mail.* /var/log/maillog

Upvotes: 0

Pekka
Pekka

Reputation: 449415

Is php mail() function returns delivery status

No. There is no common way to tell an E-Mail's actual delivery status. mail() will tell you only whether the E-Mail has been accepted by the outgoing server.

Here is a list of approaches to request a delivery notice, but none of them is waterproof.

If you have trouble with E-Mail arriving, there are several related SO questions, among them this one.

Upvotes: 2

ThiefMaster
ThiefMaster

Reputation: 318508

It returns a status telling you if it has been successfully delivered to the MTA responsible for actually sending the mail. You cannot find out if the mail has been actually delivered to its recipient or not without setting up a special mailbox which receives bounces for your emails. If you decide to create one and set the headers to ensure bounces go there remember that it might take some time before a bounce arrives so right after calling mail() and getting a TRUE return value, you simply have to assume the mail has been sent successfully.

Upvotes: 1

Related Questions