我有这个代码。它打印“消息已成功发送”,但我的收件箱中没有来自我的测试的消息。
这是HTML代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Basic Email Form</title>
<style>
* {
margin:0;
padding:0;
}
input, textarea {
margin:10px;
font-family:Arial, sans-serif;
padding:10px;
}
input {
width:280px;
height:40px;
}
textarea {
width:280px;
height:120px;
}
</style>
</head>
<body>
<form action="submit.php" method="post">
<input type="text" name="name" placeholder="Name" /><br />
<input type="text" name="from" placeholder="Email" /><br />
<textarea placeholder="Message" name="message"></textarea><br />
<input type="submit" value="Submit" />
</form>
<body>
</html>
PHP 文件:
<?php
$to = "prefertodie@gmail.com";
$subject = "This is subject";
$message = "This is simple text message.";
$header = "From:".$_POST['from']." \r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true )
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
?>