php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12335 mail() function returns false but the email was sent.
Submitted: 2001-07-24 08:03 UTC Modified: 2002-06-02 19:54 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: sascha dot winkler at ks dot sel dot alcatel dot de Assigned:
Status: Not a bug Package: Mail related
PHP Version: 4.1.2 OS: Sun Solaris 2.6
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 !
Your email address:
MUST BE VALID
Solve the problem:
41 - 18 = ?
Subscribe to this entry?

 
 [2001-07-24 08:03 UTC] sascha dot winkler at ks dot sel dot alcatel dot de
I had first the bug with id 12024 and I have fixed it like described in the bug report.
Now I can send mails, but the mail() function returns false altough the mail was sent.
I use the following script to test the mail() function.
 

<?php

            $mail_to = "sascha.winkler@t-online.de";
            $mail_subject = "PHP test mail() gesendet obwohl failed gemeldet.";
            $mail_body = " i hope that this mail() function works ! \n";
            $mail_body .= " this is supposed to come on the second line \n";
            $mail_body .= " and this on the third line \n";

            if (mail($mail_to, $mail_subject, $mail_body))
                    echo "Successfully sent the email \"$mail_subject\" to $mail_to .";
            else echo "Failed to send the e-mail \"$mail_subject\"." ;
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-07 07:45 UTC] sascha dot winkler at ks dot sel dot alcatel dot de
I found out, that the problem is not the EX_OK or EX_TEMPFAIL but the sendmail return value.
Sendmail (the sendmail qmail wrapper) is returning the value -1 when I call it with php 4.0.6.
When I call it with 4.0.4pl than 0 is returned.
What could be the reason for this behaviour?


 [2002-03-15 07:28 UTC] glen at designsolution dot co dot uk
More information:

Basically, the mail function was returning false even 
though the email was being sent.  Here is an example:

if ( mail( 'glen@designsolution.co.uk', 'test', 'test2', 
"From: webmaster@$SERVER_NAME\r\nReply-To: 
webmaster@$SERVER_NAME\r\nX-Mailer: PHP/" . phpversion(), 
"-fstupid@webapproval.co.uk" ) ) {
	echo "mail sent okay";
}
else {
	echo "mail cannot be sent!";
}

The problem only occurs if you include the 5th parameter 
and the -f email address is not set up on the local 
machine.  For example, PHP is running on the same machine 
as the webapproval.co.uk domain.  If the user 'stupid' 
hasn't been set up, then sendmail will complain:

sendmail[21956]: JAA21956: setsender: 
stupid@webapproval.co.uk: invalid or unparseable, received 
from httpd@localhost

but will still send the mail.  So essentially, sendmail is 
returning an error code, but still sending the mail.  The 
return address is set to httpd@<my server address>.
 [2002-06-02 19:54 UTC] mfischer@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Oct 19 09:03:37 2021 UTC