2

I have read I believe every post on here related to this. I have a feeling that this is Linux file rights related, but not to sure. My environment is a test Centos7 box running Apache 2.4 and Php7 with phpMyAdmin etc. I can send mail using the sendmail somename@domain.com. I have tested this.
In my php.ini file(s) I have "sendmail_path = /usr/sbin/sendmail -t -i;"

$to = "Jesse.---@-----------.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
            "CC: somebodyelse@example.com";
$mail = mail($to,$subject,$txt,$headers); //I have tried with no headers as well.

The mail function returns a false.

Francisco
  • 10,918
  • 6
  • 34
  • 45
Jesse Owen
  • 23
  • 1
  • 1
  • 4

1 Answers1

1

This problem can have so many reasons, that's why I am not using mail() anymore, I use PHPMailer with an external SMTP (GMAIL for example), but if you still want to use mail(), make sure that Sendmail, Exim or Postfix is installed on your server.

Test the mail() on the terminal first, if you can send on terminal, the problem may be some configuration on the php.ini, if the message fails on the terminal, you need to check the Postfix / Sendmail / Exim logs for the error message.

Make sure with your server provider too, if you are authorized to use mail(). Some servers block this function due to spam, and they require manual authorization.

bruno
  • 151
  • 9
  • I will check this in the morning. I didn't have Exim on the server. I will also looking into phpmailer as well. – Jesse Owen Nov 22 '16 at 23:58
  • Right. You just need one of the three programs, it's recommended to have just one, I used only postfix in the past. If you have postfix and sendmail installed, it may get some conflict, and make sure to check all logs when the message fails. – bruno Nov 23 '16 at 00:01