没有收到PHP邮件?
可能重复:没有收到PHP邮件?,php,forms,email,hotmail,Php,Forms,Email,Hotmail,可能重复: 我在我的网站上有这个简单的表单,当它发送到我的Hotmail帐户时,我不会收到电子邮件,甚至不会收到垃圾邮件文件夹 以下是表格代码: <form action="mail.php" method="POST"> <p><label title="Name">Name:</label><br /> <input type="text" name="name" autocomplete="on"
我在我的网站上有这个简单的表单,当它发送到我的Hotmail帐户时,我不会收到电子邮件,甚至不会收到垃圾邮件文件夹 以下是表格代码:
<form action="mail.php" method="POST">
<p><label title="Name">Name:</label><br />
<input type="text" name="name" autocomplete="on" required="required"></p>
<p><label title="Email">Email:</label><br />
<input type="text" name="email" autocomplete="on" required="required"></p>
<p><label title="About">My message is about...</label><br />
<select name="about">
<option value="general">General Query</option>
<option value="wedding">Wedding</option>
<option value="corporate">Corporate Event or Trade Show</option>
<option value="other">Other Event</option>
</select>
<p><label title="Message">Message:</label><br />
<textarea name="message" rows="6" cols="25" required="required"></textarea></p>
<input type="submit" value="Send">
</form>
名称:
电子邮件:
我的留言是关于…
一般查询
婚礼
企业活动或贸易展览
其他事件
消息:
以及mail.php文件:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$about = $_POST['about'];
$formcontent="From: $name \n About: $about \n Message: $message";
$recipient = "MyEmailAddress@Live.co.uk";
$subject = "Contact Form";
$mailheader = "Reply-To: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
最后我确实看到一个显示“谢谢!”的页面,但没有收到任何电子邮件。邮件传递是一项棘手的工作。。。仅仅因为你发送邮件并不意味着任何人都会收到它。如果传入的邮件不符合某些标准,许多接收服务器将直接忽略它(根据我的经验,Gmail和Hotmail特别倾向于默默地拒绝传递,因此它甚至不会以垃圾邮件结束)。有几件事要确保你做到了: 1) 您已经在DNS记录中设置了PTR/(反向查找)项 2) 确保你不在任何黑名单上() 3) 展开标题
$headers = "MIME-Version: 1.0\r\n"
."Content-Type: $contentType; charset=utf-8\r\n"
."Content-Transfer-Encoding: 8bit\r\n"
."From: =?UTF-8?B?". base64_encode("Your sending display name") ."?= <$from>\r\n"
."Reply-To: $replyTo\r\n"
."X-Mailer: PHP/". phpversion();
$headers=“MIME版本:1.0\r\n”
“内容类型:$contentType;字符集=utf-8\r\n”
“内容传输编码:8位\r\n”
“发件人:=?UTF-8?B?”。base64_编码(“您发送的显示名称”)。“?=\r\n”
“答复:$replyTo\r\n”
“X-Mailer:PHP/”。phpversion();
但是,如果您真的想确保邮件能够通过,请发送邮件。你永远不能保证邮递,但它会更可靠。如果您没有发送大量邮件,您可以尝试使用或类似的服务为您转发电子邮件。您可以使用以下方法。成功时返回true
function sendMail($email, $subject, $message)
{
$supportEmail = 'info@abc.com';
$from = 'Abc';
$msg = $message;
$from = str_replace(' ', '-', $from);
$frm = $from.' <'.$supportEmail.'>';
preg_match("<(.*)@(.*\..*)>", $frm, $match);
///////////////////Headers/////////////////
$hdr='';
$hdr.='MIME-Version: 1.0'."\n";
$hdr.='content-type: text/html; charset=iso-8859-1'."\n";
$hdr.="From: {$frm}\n";
$hdr.="Reply-To: {$frm}\n";
$hdr.="Message-ID: <".time()."@{$match[2]}>\n";
$hdr.='X-Mailer: PHP v'.phpversion();
$x=@mail($email, $subject, $msg, $hdr);
if($x==0)
{
$email=str_replace('@','\@', $email);
$hdr=str_replace('@','\@',$hdr);
$x=@mail($email, $subject, $msg, $hdr);
}
return $x;
}
函数sendMail($email、$subject、$message)
{
$supportEmail='1info@abc.com';
$from='Abc';
$msg=$message;
$from=str_替换(“,-”,$from);
$frm=$from';
预匹配(“,$frm,$match);
///////////////////标题/////////////////
$hdr='';
$hdr.='MIME-Version:1.0'。“\n”;
$hdr.='content-type:text/html;charset=iso-8859-1'。“\n”;
$hdr.=“发件人:{$frm}\n”;
$hdr.=“回复:{$frm}\n”;
$hdr.=“邮件ID:\n”;
$hdr.='X-Mailer:phpv'.phpversion();
$x=@mail($email,$subject,$msg,$hdr);
如果($x==0)
{
$email=str_replace('@','\@',$email);
$hdr=str\u replace('@','\@',$hdr);
$x=@mail($email,$subject,$msg,$hdr);
}
返回$x;
}
检查您的日志。检查一下你的日志。然后告诉我们邮件是否发出。不,你永远不会知道是否收到了邮件。顺便说一句,从本网站现有的问答材料中很容易掌握这些信息。另外:如果有返回值,请检查它。很容易排除故障。为什么不使用SMTP服务