I was having trouble getting my mail php mail script to work yesterday but I finally got it going. Now I just turned my computer back on after a shutdown and its not working again. I am getting this message in my mail.log:

Oct 1 11:22:26 alexander-repennings-imac postfix/sendmail[352]: fatal: Recipient addresses must be specifie\ d on the command line or via the -t option Oct 1 11:22:26 alexander-repennings-imac postfix/master[354]: daemon started -- version 2.4.3, configuratio\ n /etc/postfix Oct 1 11:23:26 alexander-repennings-imac postfix/master[354]: master exit time has arrived

The PHP script looks like this:

if(isset($_POST['submit'])) {

  $to = "[email protected]"; 
  $subject = "Competition Submission";
  $name_field = $_POST['name'];
  $email_field = $_POST['email'];

  $value_field = $_POST['sendvalue'];

  $body = "From: $name_field\n E-Mail: $email_field\n  Value: $value_field\n";

  if(mail($to, $subject, $body))
   echo "Data has been submitted to $to!";
   echo "failure";

      } else {
           echo "blarg!";

Which is once again echoing failure.

+2  A: 

probably the sendmail_path value isn't set in php.ini. Open it to see if the following line is uncommented*

sendmail_path = /usr/sbin/sendmail -t

Worked for me once.

*assuming you are running on Unix system

I was missing the -t, thanks

I gave up on trying to get PHP work with the mail command long ago. Usually it worked, but on hosted systems it always seemed to be an issue. I switched to SwiftMailer, which is a PHP emailing tool. You can login to just about any host, including gmail, and send emails from there.

Brent Baisley