Unanswered: mail() doesn't works but sendmail works ?¡!¿
Hi to you all.
I have my server (red hat 8 fully updated) with the xampp project (apache 2.0.47, latest php, latest mysql, and so on...) installed.
I'm trying to use the php mail() function to send feedback from my site but i can't get it working. First of all I've disabled safe_mode (not a good idea) to avoid problems.
I've tested my code on other servers using xampp (on a windowsxp) and works OK (but the config is different from the redhat8 server), so it's not a coding problem.
Mail() function returns 1 if the sendinf was ok and I allways get a 1, so I suppose the sending was OK but.. NO. I never receive that e-mail. As mail() uses sendmail I tried to use sendmail from the command line and.. works perfect so ¿where is my problem? ¿permission matters? APache runs as user www
Hmm. Can you post an example of your mail script? I know on the RH server our host uses, I have to pass an additional argument to mail(), which basically fools sendmail in sending it from a specific user. The fifth argument which is "-f email@example.com". So our mail script makeup is like this:
$to = "firstname.lastname@example.org";
$sub = "Testing PHP";
$msg = "Hey, read the subject line!";
$headers = "From: Good Guy <email@example.com>\n";
$extra = "-f [email]firstname.lastname@example.org[/email]";
if (!$mail = mail($to, $sub, $msg, $headers, $extra))
die("Could not send email.");
echo "Mail sent.";
I also notice you don't have your sendmail path specifically configured in the php.ini file; now, this isn't strictly necessary, but you should check your phpinfo() to verify where PHP thinks sendmail is.
Just a thought.