PDA

View Full Version : php mail() failing?



Sifodyas
August 9th, 2006, 01:09 PM
I was implementing the tutorial-based code and was having no end of difficulty working out why I was not receiving the emails.

So, one thing I tried was to directly call up the email.php file by typing in the full path and it seems that if I do a if (mail(....)) check that it returns a false result suggesting that the mail command failed.


<?php

$email = "noone@nowhere.com";
$name = "no one";
$sentTo = "**mygmailaccount**";
$subject = "test subject";
$headers = "From: " . $name . "<" . $email . ">\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$headers .= "Return-Path: " . $email;
$message = "this is a test";

if (mail($sendTo, $subject, $message, $headers))
{
echo "Message was sent.";
}
else
{
echo "Message was not sent?!";
}
?>
Each time I call the email.php directly, I get the Message was not sent response.

I've setup a phpinfo file here (http://www.birkvideo.com/proof/test.php), but I'm not sure how to validate any of this.

Different email accounts (which are operating fine) were tried.

I've already gone through the forum archives and can not see a solution, so I really could do with some help on this one.

Any help would be greatly appreciated.

Cheers.

Jeff Wheeler
August 9th, 2006, 01:13 PM
Do you have it connected to a valid smtp server?

Sifodyas
August 9th, 2006, 01:18 PM
I have absolutely no idea.

How do I find out or go about getting this done?

Note, the phpinfo() reports:



sendmail_from no value
sendmail_path /usr/sbin/sendmail -t -i
SMTP localhost
smtp_port 25

Jeff Wheeler
August 9th, 2006, 01:20 PM
Uh, is /usr/sbin/sendmai a real file?

Sifodyas
August 9th, 2006, 05:47 PM
No idea. This whole thing is alien to me.

I assumed the webhost would have defined all that is neccessary in the php configuration to get things working. Was this assumption wrong?

Jeff Wheeler
August 9th, 2006, 05:48 PM
Oh, the host set it up? Contact their support and they should help…

Sifodyas
August 9th, 2006, 07:25 PM
Ah, the shroud of the dark side has been lifted!

It turns out this sodding webhost is using FormMail.

After doing some searching on this site, it sounded like this would be a pain in the butt to implement but I've just got the whole thing working.

Many thanks for your patience and assistance. :beer: