开发者

Why isnt this PHP Mailer for HTML Forms working?

开发者 https://www.devze.com 2023-04-03 16:43 出处:网络
This is the PHP code: <?PHP 开发者_如何学运维$to = \"adschweinfurth@gmail.com\"; $subject = \"New Finance Request\";

This is the PHP code:

<?PHP 
开发者_如何学运维$to = "adschweinfurth@gmail.com"; 
$subject = "New Finance Request";
$headers = "Request:";
$forward = 0; 
$location = "";

$date = date ("l, F jS, Y"); 
$time = date ("h:i A"); 

$msg = "Below is the request sent on $date at $time.\n\n"; 

if ($_SERVER['REQUEST_METHOD'] == "POST") {
    foreach ($_POST as $key => $value) { 
        $msg .= ucfirst ($key) ." : ". $value . "\n"; 
    }
}
else {
    foreach ($_GET as $key => $value) { 
        $msg .= ucfirst ($key) ." : ". $value . "\n"; 
    }
}

mail($to, $subject, $msg, $headers); 
if ($forward == 1) { 
    header ("Location:$location"); 
} 
else { 
    echo "Thanks!  Your request has been sent for approval and someone will be in contact with you soon!"; 
} 

?>

This is the HTML code:

<form action="mailer.php" method="post">
<strong>Name:</strong><br />
<input type="text"  name="Name" />
<br />
<br />
<strong>Email:</strong><br />
<input type="text" name="Email" />
<br />
<br />
<strong>Organization:</strong><br />
<input type="text" name="Org:" />
<br />
<br />
<strong>Amount:</strong><br />
<input type="text" name="Amount" />
<br />
<br />
<strong>Explain Request:</strong><br />
<textarea rows="5" cols="30" name="Message"></textarea>
<br />
<hr />
<input type="submit" name="submit" value="Submit">
</form>

I can not for the life of me get it to actually send the email. It goes to the thanks page, but I never receive any email...Let me know, comment below.


Put it up like this if email is really sent or if there is an error:

if (mail($to, $subject, $msg, $headers)){
  // email sent
}
else {
  echo 'some error occurred !';
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号