|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30822 mail function returns nothing or false, but sends mail
Submitted: 2004-11-18 09:28 UTC Modified: 2005-01-27 01:00 UTC
Avg. Score:4.5 ± 0.8
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:1 (20.0%)
From: ligiana_s at virgilio dot it Assigned:
Status: No Feedback Package: Mail related
PHP Version: 4.3.4, 5.0.2 OS: Solaris 5.8
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: ligiana_s at virgilio dot it
New email:
PHP Version: OS:


 [2004-11-18 09:28 UTC] ligiana_s at virgilio dot it
use of mail() function, 4 parameters...Mail function sends mail, but it returns false or 'nothing'. I didn't find any error in any logs (php, apache,sendmail). Server: Solaris 5.8, php 5.0.2 (or 4.3.4 - it doesn't make difference!), apache 2.0 (xampp).

sendmail_path /usr/lib/sendmail -t -i /usr/lib/sendmail -t -i
PATH /usr/local/bin:/bin:/usr/bin:/usr/sbin:/usr/local/sbin I am not supposed to change the above PATH, but I've made even something like ln -sf /usr/lib/sendmail /usr/bin/sendmail

Reproduce code:
$r = false; 
$fdate = date("d-m-Y"); $subject = "New request - $HTTP_HOST "; 
$msg_body = "\nDate: 15 nov 2004 \n"; 
$headers = "From:\n"; 
$headers .= "X-Priority: 1\n"; 
$r = @mail("", $subject, $msg_body, $headers);
  echo "Mail sent"; 
?> <div align="center" class="main"><p><?php echo
isset($r)."/".empty($r)."/Error"; ?> !!!</b></div>M

Expected result:
 "Mail sent" when the mail was successfully accepted for delivery;
 "1/1/Error !!!"
if the mail wasn't sent.

Actual result:
Sometimes returns "Mail sent", and most of the times returns "1/1/Error
!!!", but in both cases the mail has been sent. I couldn't determine when is made the diference. I don't find anything in logs.

I wanted to report this on 4.3.4 version, but I saw that I was not allowed and I upgraded to 5.0.2, as recommended. 5.0.2 made a mess through my software, one of the problems being  the well-konwn "PHP Fatal error:  Cannot re-assign $this in..". I'll get back to 4.3.4, but please let me know what should I do in order to use the mail() function properly..


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-19 21:24 UTC]
Please try using this CVS snapshot:
For Windows:

PHP 5 is not the only release. We still consider PHP 4.3.x to be stable and valid release too. Try the snapshot, I can not reproduce this. (I'd also check the sendmail log(s) if it has some warning, etc. when the erronous false is returned but mail still send.)

 [2005-01-27 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 17 06:01:28 2024 UTC