Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail() returning TRUE but not sending e-mail

Status
Not open for further replies.

joshbula

Technical User
Nov 19, 2004
45
US
Hello, I am using the code below to try to send mail, and it is returning TRUE, but the recipients are not recieving the messages. I have tried with several e-mail addresses that are known to be good, and have checked for spam filtering as well. The sendmail binary is in the path, and the mail() function is working fine with other scripts on the site. Any help would be greatly appreciated.
Code:
echo("<pre>$body</pre>");

$subject="Your SCDBA Registration";
$headers='From: webmaster@scdba.org';

if (mail($semail, 'Your SCDBA Registration', $body, 'From: webmaster@scdba.org')) {
     echo("An E-mail confirmation has been sent to $semail .  ");
       } else { echo("An error occurred sending mail to $semail but your registration has been submitted.");
       }

        
if (mail($hemail, 'Your SCDBA Registration', $body, 'From: webmaster@scdba.org')) {
     echo("An E-mail confirmation has been sent to $semail .  ");
       } else { echo("An error occurred sending mail to $hemail but your registration has been submitted.");
       }
 
PHP's mail() function returns true if the message was accepted for delivery. (Basically, if PHP can successfully hand the message off to a mail server, mail() will return true.) This does not guaranty delivery.

As a first start to debugging this, I recommend that you examine the activity logs of your mail server. Since the message was handed off successfully, the problem likely lies in the delivery phase at the mail server.



Want the best answers? Ask the best questions! TANSTAAFL!
 
This may or may not make a difference but I believe all Headers must end w/ a CRLF in order to be a proper header.
Code:
'From: webmaster@scdba.org\r\n'
Hopefully that will take care of it. Like sleipnir said it will confirm that it can be sent but will not send with deformed headers.
 
Error logs aren't showing anything related to this, and I tried putting the CRLF in the header and it still isn't working.

Any other ideas?

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top