3

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

代码:

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;
}

错误在哪里?

4

1 回答 1

5

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

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

  1. 确保发送电子邮件的计算机具有反向 PTR 记录
  2. 在您的 DNS 和代码中配置 DomainKeys 识别邮件
  3. 在您的 DNS 中设置 SenderID 记录

您还应该使用类似这样的 blacklist checker来查看您的服务器是否在任何黑名单上。如果您是其中之一,那么在您清理列表之前,您所做的任何事情都无济于事。

于 2012-07-22T15:45:52.120 回答