|  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: 2017-10-23 01:13 UTC
Avg. Score:3.8 ± 1.5
Reproduced:4 of 5 (80.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
5 + 46 = ?
Subscribe to this entry?

 [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
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 02:01:27 2019 UTC