我有一个简单的模板,我一直用它来发送电子邮件给我的网站用户使用php。
我现在注意到,由于一些奇怪的原因,gmail似乎认为我的电子邮件是垃圾邮件,因此我的网站发送到gmail地址的每封邮件都会被发送到垃圾邮件文件夹。
由于域名是一个新域名,我怀疑其原因是由于我的网站被标记为以某种方式分发垃圾邮件的网站,所以我得出的结论是它必须归结为我的html用户和可能的我使用超链接的方式。
如果有人可以查看我在下面的简短示例,并向我解释我在所有这些中做错了什么,我会非常感激,因为我现在已经摸不着头脑了,这似乎是是否有效且符合规范?
欢迎任何意见,建议,反馈或想法,谢谢!
<?php
// multiple recipients
$to = "exampleuser@gmail.com";
// subject
$subject = 'Please Confirm User Account Registration';
// message
$message = '
<html>
<head>
<title>My Domain User Account Registration</title>
</head>
<body>
<p>My Domain User Account Registration :</p>
<p>We have just received a request to have your information added to our website as a user account. This would enable you to buy products on our website at <a href="http://www.mydomain.com/">http://www.mydomain.com/</a></p>
<p>If this is correct and you do wish to create a new user account on our website, please click the link below to be directed our website.</p>
<p><a href="http://www.mydomain.com/users/register/confirmation/confirm.php?confirm=12345&key=12345abcde">http://www.mydomain.com/users/register/confirmation/confirm.php?confirm='.$userId.'&key='.$randomKey.'</a></p>
<p>If you received this email by mistake, simply delete it. You won’t be subscribed if you don’t click the confirmation link above and your email address will be removed from our database by tomorrow.</p>
<p>For questions about this message, please contact us at : <a href="mailto: info@mydomain.com">info@mydomain.com</a></p>
<p>Thank you.</p>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: Accounts @ www.mydomain.com <accounts@mydomain.com>' . "\r\n";
//Send the message
mail($to, $subject, $message, $headers);
?>
答案 0 :(得分:1)
如果可以的话,请拿出:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
然后,您将以纯文本形式发送电子邮件,并且不会将其自动检测为垃圾邮件。
答案 1 :(得分:0)
在对主题进行了相当长时间的讨论之后,事实证明他们的服务器基本上被标记为垃圾邮件的发件人,因此来自我的网站上的邮件已经被自动发送到垃圾邮件gmail用户的文件夹......
要注意的事情!