【发布时间】:2016-10-10 06:30:20
【问题描述】:
我在 html 网站中使用此代码作为我的联系表单,但 Gmail 收件箱中没有邮件。
谁能帮我解决这个问题,但我没有任何指南。
<?php
session_cache_limiter( 'nocache' );
$subject = $_REQUEST['subject']; // Subject of your email
$to = "iamuser@gmail.com"; //Recipient's E-mail
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= "From: " . $_REQUEST['name'].'<'.$_REQUEST['email'] .'>'. "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = 'Name: ' . $_REQUEST['name'] . "<br>";
$message .= 'Company: ' . $_REQUEST['company'] . "<br>";
$message .= $_REQUEST['message'];
if (@mail($to, $subject, $message, $headers))
{
// Transfer the value 'sent' to ajax function for showing success message.
echo 'sent';
// header('Location: ../index.html');
}
else
{
// Transfer the value 'failed' to ajax function for showing error message.
echo 'failed';
}
?>
【问题讨论】:
-
使用邮件函数代替 at.mail,at.mail 函数不会抛出所有警告/错误
-
检查垃圾邮件。
-
请注意,您需要提及正确的 From Mail Id。几天前我也遇到了同样的问题。
标签: php html email gmail contact-form