|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #21165 Improve mail() error handling
Submitted: 2002-12-23 05:42 UTC Modified: 2021-07-06 15:50 UTC
Avg. Score:3.9 ± 1.4
Reproduced:6 of 7 (85.7%)
Same Version:4 (66.7%)
Same OS:4 (66.7%)
From: tit dot petric at telemach dot net Assigned:
Status: Analyzed Package: Mail related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: tit dot petric at telemach dot net
New email:
PHP Version: OS:


 [2002-12-23 05:42 UTC] tit dot petric at telemach dot net
mail is probably the most common used function with the worst set of error reporting available to it

mail() returns true on success and false on error, but this "false" is all you can get with php, when as you have to examine the mailer logs to see if the message acctually failed (i for example get false on the mail() function, but the email is queued and sent with sendmail)

there should be atleast somekind of trigger_error() sequence which would spew out a few E_NOTICE or E_WARNING triggers depending on the progress of mail() - for example.. if the sendmail_path directive isn't configured properly, some incorrect data (any of the parameters beeing null, empty or not set), or you cant connect to the mail server (windows - only guessing that it doesnt report that), or whatever kind of message the mailer spews out resulting in true/false

any kind of verbosity, even if only trough E_NOTICE or E_WARNING would really be appreciated, a simple true or false is just not enough when tracking down why mail() returns false.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 17:48 UTC]
-Summary: mail() is not descriptive enough +Summary: Improve mail() error handling -Package: Feature/Change Request +Package: Mail related -Operating System: all +Operating System: * -PHP Version: 4.3.0RC4 +PHP Version: *
 [2017-10-23 01:13 UTC]
-Status: Open +Status: Analyzed
 [2017-10-23 01:13 UTC]
I think this for one, could be handy or at least to improve mail() in general to not only include more detailed errors but also a proper API for things like attachments
 [2021-07-06 15:50 UTC]
> but also a proper API for things like attachments

I'd leave this for userland (or to use imap_mail_compose()).

I'm fine with more diagnostics, but that doesn't solve the general
issue that you can't know whether the mail actually has been sent,
let alone that the recipient will receive it.

Anyhow, this feature request actually will go nowhere, unless
someone provides a PR.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Oct 19 03:03:34 2021 UTC