0

Excuse me, I am learning to build a simple contact form on my customed website. I want to send an email via mail() but no mails are received. How do I set it via Sendmail path?

PHP mail official manual

<?php
if (isset($_POST['email'])) {

//Email information
$to="admin@example.com";
$subject='New Form Submission';
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$message=$_POST['message'];

//send email
mail($to,$subject,$message);

header('Location:success.html');
}

?>
Lyu JH
  • 131
  • 9
Joseph
  • 80
  • 14
  • Have a look at this answer - https://stackoverflow.com/a/24644450/4383900. Also try setting the FROM address – Amit Joshi Feb 20 '19 at 03:42
  • @Joshi I solved the problem via additional parameter-f. mail($to,$subject,$message, null,'-fadmin@example.com'); – Joseph Feb 20 '19 at 15:36

2 Answers2

0

You are setting the address you want the mail to be sent to as 'admin@example.com.' you should change it to mail($email, $subject, $message);

0

//send email

mail($to,$subject,$message,youremail@example.com);
kealaxshan
  • 338
  • 2
  • 14