php邮件功能直接进入垃圾文件夹 [英] php mail function goes straight to junk folder

查看:57
本文介绍了php邮件功能直接进入垃圾文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个包含基本字段的联系表。将该表单发送给站点所有者,并将一条消息发送给提交表单的客户。该功能有效,但始终将邮件发送到垃圾文件夹。我的标头有问题吗?或者仅仅是hotmails垃圾设置。

I have set up a contact form, with basic fields. The form is sent to the site owner and a message sent to the customer submitting the form. The function works but allways send the message to the junk folder. Is there something wrong with my headers or is it just hotmails junk settings.

$headers = "MIME-Version: 1.0rn"; 
$headers .= "Content-type: text/html; charset=iso-8859-1rn"; 
$headers  .= "From: contact@mysite.com\r\n"; 
mail($to, $subject, $message, $headers)or die("mail error");

邮件是HTML电子邮件,只是显示邮件的一种更好的方式。同样在我的电子邮件帐户中,不是显示我的变量,而是显示 CGI Mailer-令人困惑。

The message's are HTML emails, just a nicer way of displaying the message. Also in my email account instead of displaying my from varable it says ,' CGI Mailer' -- confusing.

更新-不再起作用

//mail customer
$from = 'donotreply@mysite.co.uk';
$subject = 'Your message has been recieved.';

$headers = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$headers .= 'From: My Site <'.$from.'>' . "\r\n";

$msg = '
<html>
<head>
<link href="http://linktocss/.../etc" rel="stylesheet" type="text/css" />
</head>
<body>
formatted message...
</body>
</html>
';
mail($email, $subject, $msg, $headers)or die("mail error");


推荐答案

编辑


这对我有用,但最终并没有出现在垃圾邮件/垃圾邮件中,而是在我的收件箱中。

Edit

This worked for me, and did not end up in SPAM/Junk, but in my Inbox.

<?php
//mail customer
$from = 'donotreply@mysite.co.uk';
$to = "email@example.com";
$subject = 'Your message has been received.';

$headers = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$headers .= "From: The Sending Name <$from>\r\n";

$msg = '
<html>
<head>
<link href="http://linktocss/.../etc" rel="stylesheet" type="text/css" />

</head>
<body>
formatted message...
</body>
</html>
';
mail($to, $subject, $msg, $headers)or die("mail error");

?>

脚注::我注意到您使用的是外部样式表。许多电子邮件服务(例如Google)不会提供这些服务。最好使用 内嵌样式 以获得更好/期望的结果。

Footnotes: I noticed that you are using an external stylesheet. Many Email services such as Google will not render those. It's best to use inline styling to achieve better/desired results.

最有可能)原因(按照您发布的代码),导致邮件最终以垃圾邮件结尾的原因是您的标题无效。

The (most likely) reason (as per your posted code) why your mail ends up in SPAM is that your headers are invalid.

您有 rn 捆在一起,而不是使用 \r\n

You have rn bunched up together, instead of using \r\n

请改用此:

$headers = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$headers  .= "From: contact@mysite.com\r\n"; 
mail($to, $subject, $message, $headers)or die("mail error");

或更妙的是,使用:取自> $code> PHP网站的mail()函数

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers  .= "From: contact@mysite.com\r\n"; 
mail($to, $subject, $message, $headers)or die("mail error");

这篇关于php邮件功能直接进入垃圾文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆