这是我第一次使用邮件功能。我尝试使用它发送邮件,代码告诉我它“已成功发送”,但我没有收到任何邮件。我很困惑阅读很多关于此的文章。请帮我。
<?php
if(isset($_POST['author'])&& isset($_POST['subject'])&& isset($_POST['text'])) {
//Email
$email_to = "lucy@yahoo.com";
$email_subject = "Query From HYPERMARKETS";
$name = $_POST['author']; // required
$sub = $_POST['subject']; // required
$comments = $_POST['text']; // required
echo "POST:".$name.$sub.$comments;
$error_message = "";
$string_exp = "^[a-z .'-]+$";
if(!strcmp($string_exp,$name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 5) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
echo ("<center><table border=1 cellspacing=5 cellpadding=5><tr><th>$error_message</th></tr></table></center>");
}
$email_message = "Form details below.\n\n";
$email_message .= "Name: ".$name."\n";
$email_message .= "Subject: ".$sub."\n";
$email_message .= "Comments: ".$comments."\n";
// create email headers
$headers = "From: mary@yahoo.com \r\n Reply-To: mary@yahoo.com \r\n" ;
if(@mail($email_to, $email_subject, $email_message, $headers))
echo "<center><table border=1 cellspacing=5 cellpadding=5><tr><th>MESSAGE SENT SUCCESSFULLY</th></tr></table></center>";
else
echo "<center><table border=1 cellspacing=5 cellpadding=5><tr><th>MESSAGE NOT SENT</th></tr></table></center>";
}
else
echo ("<center><table border=1 cellspacing=5 cellpadding=5><tr><th>FILL ALL THE FIELDS..!!</th></tr></table></center>");
?>
嘿,我已将我的 php.ini 文件配置为
[mail function]
sendmail_from = postmaster@localhost
SMTP = localhost
smtp_port = 25
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
sendmail_path = "C:\xampp\mailtodisk\mailtodisk.exe"
它仍然不起作用。