php.net |  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: 2022-04-07 14:33 UTC
Votes:8
Avg. Score:4.0 ± 1.3
Reproduced:7 of 8 (87.5%)
Same Version:5 (71.4%)
Same OS:5 (71.4%)
From: tit dot petric at telemach dot net Assigned: ilutov (profile)
Status: Closed Package: Mail related
PHP Version: * OS: *
Private report: No CVE-ID: None
 [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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 17:48 UTC] jani@php.net
-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] kalle@php.net
-Status: Open +Status: Analyzed
 [2017-10-23 01:13 UTC] kalle@php.net
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] cmb@php.net
> 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.
 [2022-04-07 14:33 UTC] ilutov@php.net
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: ilutov
 [2022-04-07 14:33 UTC] ilutov@php.net
Nowadays most people use 3rd party libraries to send mails. That's not to say improving mail() would be useless, but as Christoph mentioned, this will go nowhere unless somebody proposes a PR. If the wish for this remains please send a PR to the master branch.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC