2015-04-06 99 views
0

當觸發我的郵件功能時,該郵件轉到「垃圾郵件」文件夾而不是「收件箱」。你能弄清楚什麼是問題?如何阻止郵件發送垃圾郵件文件夾?

function send_user_email($mail, $to_email,$password, $first_name) 
{ 
$html = "Hi $first_name, <br /><br />"; 
$html = $html . "<p> You have been registered with the system. Please find your login details below. </p>"; 
$html = $html . "User Name - $to_email <br />"; 
$html = $html . "Password - $password <br /> <br />"; 
$html = $html . "Regards, <br />"; 
$html = $html . "Team"; 

$mail->IsSMTP(); // telling the class to use SMTP 
$mail->Host = "smtpout.XXX.XXX.XXX"; // sets GMAIL as the SMTP server 
// $mail->Host= "stmp.gmail.com"; // SMTP server 
$mail->SMTPAuth = true; // enable SMTP authentication 
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier 
$mail->Port = XXX; // set the SMTP port for the GMAIL server 
$mail->Username = "mailid"; // GMAIL username 
$mail->Password = 'password';// GMAIL password 
$mail->From = "mailid"; 
$mail->FromName = "name"; 
$mail->Subject = "User invitation email"; 

$mail->AltBody = ""; // optional, comment out and test 

$mail->IsHTML(true); 
$mail->Body = nl2br($html); 

$mail->AddAddress($to_email); 

$mail->Send(); // send message 
} 

回答

0

幾件事情,你可以驗證:)

  1. 具備HTML和文本內容。
  2. 嘗試添加小而質量的HTML正文不僅僅是br's。
  3. 確認您使用的SMTP服務器已正確設置。通常,如果您使用付費SMTP,這不是一個問題,但如果您的構建它可能有問題。
  4. SPF記錄通常是一個問題,就好像他們錯過了任何郵件都會被視爲垃圾郵件一樣。
0

通常情況下,如果電子郵件的「From:」標頭值的域部分與實際發送電子郵件的域不匹配,則該電子郵件被標記爲垃圾郵件。

繞過這個最簡單的方法是使用「來源:」您的域名相匹配,並使用「回覆:」頭到您在設置「發件人:」電子郵件標題

對於例如:如果您從mydomain.com發送郵件,並且您的電子郵件地址是[email protected],則應將標題更改爲:

From: [email protected] 

Reply-To: [email protected] 
相關問題