<?php
$msg="";
if(isset($_POST['submit']))
{
$from_add = "name@your-web-site.com";
$to_add = "receiver@gmail.com"; //<-- I replaced this with my real gmail account
$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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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='submit' name='submit' value='Submit'>
</form>
</p>
</body>
</html>
我从http://www.html-form-guide.com获得了这段代码,它说如果正确配置为发送电子邮件,它将检查我的服务器的配置。
我试过了,我上传到我的域,当我打开它时,它显示回显“邮件发送正常”,但我没有收到邮件。
请帮我。