繁体   English   中英

gmail忽略来自php联系人表单的电子邮件

[英]gmail ignoring emails from a php contact form

我们在网站上使用php电子邮件表单,当将电子邮件传递给其他电子邮件程序时,它可以正常工作,只是不使用gmail,我检查了垃圾邮件和收件箱,但我什么也没收到,好像gmail dosnt信任电子邮件并完全忽略了它。 我们怎样才能使它们通过?

我在表单中使用的代码是:

<div id="contact-form">
<form id="commentForm" action="assets/php/mail.php" method="POST">
<input type="text" name="name" class="required" placeholder="Name..">

<input type="text" name="email" class="required email" placeholder="Email..">

<input type="text" name="phone" class="required" placeholder="Phone..">

<textarea name="message" placeholder="Message.." class="required"></textarea><br />

<input class="subm" type="submit" value="Submit..">
</form>
</div>

而PHP是

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Contact Form Confirmation</title>

<meta http-equiv="refresh" content="4; url=http://www.domain.co.uk">
</head>

<body>

<?php $name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent="
<h1>From :</h1> $name \n
<h1>Email :</h1> $email \n
<h1>Phone :</h1> $phone \n 
<h1>Message :</h1> $message
";

$recipient = "studio@domain.co.uk";
$subject = "Contact Form";
$mailheader = "MIME-Version: 1.0" . "\r\n";
$mailheader .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$mailheader .= "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");

echo("<p>Thanks for getting in touch, we'll get back to you shortly..</p>");
?>

</body>
</html>

GMail不是唯一会忽略sendmail电子邮件的邮件服务。

原因可能是您的From:标头与您的邮件服务器主机名不匹配。 如果您使用的是第三方托管,则应找出主机名(例如“ myhost.com”),然后在“发件人:”标头中使用该主机名。 然后在“答复”标题中使用正确的电子邮件地址。

$mailheader .= "Reply-To: Some One <someone@mydomain.com>\r\n"; 
$mailheader .= "Return-Path: Some One <someone@mydomain.com>\r\n"; 
$mailheader .= "From: Some One <mydomain@myhost.com>\r\n"; 
$mailheader .= "Organization: My Organization\r\n"; 
$mailheader .= "Content-Type: text/plain\r\n"; 

为了提高可传递性,您应该使用SMTP通过实际的电子邮件帐户发送邮件。

为了绝对最大化交付能力,您应该使用ESP。

另一种(更简单)的可能性...尝试使用-f选项:

mail($recipient, $subject, $formcontent, $mailheader, "-f {$email}") or die("Error!");

我在这里回答了类似的问题:

通过电子邮件从联系人表格中使用PHP发送信息

只需检查一下,我相信它具有解决您的问题所需的所有代码,至少在您不希望收到大量电子邮件的情况下如此。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM