2015-04-06 98 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] 
相关问题