Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

php - Sent mail going to spam folder?

I searched this topic but there wasn't anything useful for me.

CODE:

public function sendActivation($name, $user, $pass, $activationKey)
{
    $to = $user;
    $subject = 'Account Activation';
    $headers = "From: [email protected]
";
    $headers .= "MIME-Version: 1.0
";
    $headers .= "Content-Type: text/html; charset=UTF-8
";
    $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;
}

Where is the mistake?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Mail going to spam rarely has much to do with the code, unless you're sending spammy content.

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

  1. Make sure the computer sending the email has a Reverse PTR record
  2. Configure DomainKeys Identified Mail in your DNS and code
  3. Set up a SenderID record in your DNS

You should also see if your server is on any blacklists, using something like this blacklist checker. If you're on one, nothing you're doing is going to help until you get the listing cleared up.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...