Advertisement

Php mail() function not sending emails.

KingSushant
KingSushant

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\n";
    $headers .= "Reply-To: $from_add \r\n";
    $headers .= "Return-Path: $from_add\r\n";
    $headers .= "X-Mailer: PHP \r\n";


    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.

Comments

Sign In or Register to comment.

Welcome

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions

Advertisement

Advertisement

Copyright © InfinityFree 2017
Powered by Vanilla Forums