PHP sendmail does not send

I have a form that is PHP. This script works and says that it is successful, but I do not receive the email.   

if(isset($_POST['name']) and isset($_POST['email']) and isset($_POST['phone'])) 

{
   //setup variables from input    
 $EMAIL = "anem@il.com";    
 $inEmail = $_POST['email'];    
 $subject = "Enquiry from ".$POST['name'];   
 $name = $_POST['name'];   

 //setup message    
 $message = "Enquiry from: ".$name."\nEmail: ".$inEmail."\nPhone: ".$phone."\n\nDeparture Date: ".$departureDate."\n\nreturnDate: ".$returnDate;

 $message = wordwrap($message, 70);   


 //email enquiry details to site owner    
 if (mail($EMAIL, $subject, $message))    
 {    
  echo "Enquiry sent!";    
 } else    
 {
  echo "fail!";    
 }
?>

The message "Request Sent" appears.

I have a postfix installed and I also tried installing sendmail. I scanned the local host using nmap and the smtp port is open.

Can anyone see the reason the mail was not sent.

+3
source share
3 answers

(/var/log/maillog). , PHP, / MX .

+3

Assuming sendmail is working on your system, and that PHP is configured to use it correctly, try adding -fadditional parameters, for example ...

mail($EMAIL, $subject, $message, '-fYOURVALIDEMAILADDRESS@something.com'

This sets the envelope with the correct address. More details on the PHP website: http://www.php.net/manual/en/function.mail.php#92528

0
source

Source: https://habr.com/ru/post/1765513/


All Articles