发送邮件到垃圾邮件文件夹?

时间:2012-07-22 15:44:15

标签: php email spam

我搜索了这个主题,但没有任何对我有用的东西。

CODE:

public function sendActivation($name, $user, $pass, $activationKey)
{
    $to = $user;
    $subject = 'Account Activation';
    $headers = "From: noreply@domain.tld\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
    $message = "<div id='mail' style='height: auto; width: 500px;background-color: #DDDDDD; font-family: Tahoma, Arial, sans-serif;'>
    <p>Hello dear $name and thanks for your choise!</p>
    <p>Your details:</p>
    <p>Username: $user</p>
    <p>Password: $pass</p>
    <p><br /></p>
    <p>Here there is an activation link. Please click on it to activate your account.
    If you don't activate your account in next 24 hours, your account will be deleted automaticly.</p>
    <p><a href='" . BASE_PATH. "/register/activation/$user/$activationKey'>Activate Your Account!</a></p>
    </div>";

    if (mail($to, $subject, $message, $headers))
        return true;
    return false;
}

错误在哪里?

1 个答案:

答案 0 :(得分:5)

垃圾邮件很少与代码有很大关系,除非您发送垃圾内容。

http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html

  1. 确保发送电子邮件的计算机具有反向PTR记录
  2. 在DNS和代码中配置DomainKeys Identified Mail
  3. 在DNS中设置SenderID记录
  4. 您还应该使用this blacklist checker之类的内容查看您的服务器是否在任何黑名单上。如果你在一个人身上,那么你所做的一切都无济于事,直到你清理了这个列表。