2012-07-22 163 views
3

我搜索了這個主題,但沒有任何對我有用的東西。發送郵件到垃圾郵件文件夾?

CODE:

public function sendActivation($name, $user, $pass, $activationKey) 
{ 
    $to = $user; 
    $subject = 'Account Activation'; 
    $headers = "From: [email protected]\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; 
} 

哪裏錯了嗎?

回答

5

發送垃圾郵件很少與代碼有很大關係,除非您發送垃圾內容。

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

  1. 確保發送電子郵件的計算機具有反向PTR記錄
  2. 在您的DNS和代碼
  3. 配置域名密鑰識別郵件
  4. 成立了SenderID記錄在您的DNS

你還應該看看你的服務器是否在任何黑名單上,使用類似this blacklist checker的東西。如果你是一個人,那麼你做的任何事情都不會幫助你,直到你清理清單。

+0

噢,我的上帝:x。這真的是我想要的。在此先感謝:x – 2012-07-22 15:51:38

相關問題