Hey guys, I am trying to send a mail from php using the mail() function using sendmail but it is not being delivered. Here is the sample code that I am trying.
`$msg="";
if(isset($_POST['submit']))
{
$email = $_POST['email'];
$from_add = "admin@bloodnepal.epizy.com";
$to_add = "$email"; //<-- put your yahoo/gmail email address here
$subject = "Test Subject";
$message = "Test Message";
$headers = "From: $from_add \\r\
";
$headers .= "Reply-To: $from_add \r
";
$headers .= "Return-Path: $from_add\r
";
$headers .= "X-Mailer: PHP \r
";
if(mail($to_add,$subject,$message,$headers))
{
$msg = "Mail sent OK";
}
else
{
$msg = "Error sending email!";
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Test form to email</title>
</head>
<body>
<?php echo $msg ?>
<p>
<form action='<?php echo htmlentities($_SERVER['PHP_SELF']); ?>' method='post'>
<input type="email" name="email">
<input type="submit" name="submit" value="GO">
</form>
</p>
</body>
</html>`
In the php configuration file, the sendmail path is set to /usr/sbin/sendmail -t -i. If you guys need any more information, I’ll post it.