0

这是PHP代码:

<?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!"; 
} 

?>

这是 HTML 代码:

<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>

我一辈子都无法真正发送电子邮件。它进入感谢页面,但我从未收到任何电子邮件......让我知道,在下面发表评论。

4

1 回答 1

0

如果确实发送了电子邮件或者有错误,请这样设置:

if (mail($to, $subject, $msg, $headers)){
  // email sent
}
else {
  echo 'some error occurred !';
}
于 2011-09-08T08:16:12.503 回答