如何阻止邮件进入垃圾邮件文件夹? [重复]

时间:2020-12-04 18:14:12

This question already has an answer here:

这个问题在这里已有答案:

When trigger my mail function , that mail goes to 'spam' folder not to 'inbox'. Can u please figure out whats the problem?

当触发我的邮件功能时,该邮件将转到“垃圾邮件”文件夹而不是“收件箱”。你能搞清楚问题是什么吗?

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
}

2 个解决方案

#1


0  

Few things which you can verify :)

你可以验证几件事:)

  1. Have HTML and Text content.
  2. 拥有HTML和文本内容。

  3. Try to add small but quality HTML body not just br's.
  4. 尝试添加小而优质的HTML正文,而不仅仅是br。

  5. Verify that the SMTP server which you use is set-upped properly. Usually if you use paid SMTP's this is not a problem, but if its your build it may have problems.
  6. 验证您使用的SMTP服务器是否已正确设置。通常,如果您使用付费SMTP,这不是问题,但如果您的构建它可能有问题。

  7. SPF records are often, a problem as if they are missing any mail can/will be counted as spam.
  8. SPF记录通常是一个问题,好像它们丢失了,任何邮件都可以/将被视为垃圾邮件。

#2


0  

Normally, an email is marked spam if its "From:" header value's domain part does not match the domain that is actually sending the email.

通常,如果电子邮件的“发件人:”标头值的域部分与实际发送电子邮件的域不匹配,则会将其标记为垃圾邮件。

The easiest way to bypass this is to use a "From:" that matches your domain, and use a "Reply-To:" header to the email that you set in "From:" header

绕过此方法的最简单方法是使用与您的域匹配的“发件人:”,并使用“回复:”标题添加到您在“发件人:”页眉中设置的电子邮件

For eg: if you are sending mail from mydomain.com and your from email is me@hotmail.com, you should change your headers to this:

例如:如果您从mydomain.com发送邮件而您的电子邮件是me@hotmail.com,则应将标题更改为:

From: me@mydomain.com

Reply-To: me@hotmail.com

#1


0  

Few things which you can verify :)

你可以验证几件事:)

  1. Have HTML and Text content.
  2. 拥有HTML和文本内容。

  3. Try to add small but quality HTML body not just br's.
  4. 尝试添加小而优质的HTML正文,而不仅仅是br。

  5. Verify that the SMTP server which you use is set-upped properly. Usually if you use paid SMTP's this is not a problem, but if its your build it may have problems.
  6. 验证您使用的SMTP服务器是否已正确设置。通常,如果您使用付费SMTP,这不是问题,但如果您的构建它可能有问题。

  7. SPF records are often, a problem as if they are missing any mail can/will be counted as spam.
  8. SPF记录通常是一个问题,好像它们丢失了,任何邮件都可以/将被视为垃圾邮件。

#2


0  

Normally, an email is marked spam if its "From:" header value's domain part does not match the domain that is actually sending the email.

通常,如果电子邮件的“发件人:”标头值的域部分与实际发送电子邮件的域不匹配,则会将其标记为垃圾邮件。

The easiest way to bypass this is to use a "From:" that matches your domain, and use a "Reply-To:" header to the email that you set in "From:" header

绕过此方法的最简单方法是使用与您的域匹配的“发件人:”,并使用“回复:”标题添加到您在“发件人:”页眉中设置的电子邮件

For eg: if you are sending mail from mydomain.com and your from email is me@hotmail.com, you should change your headers to this:

例如:如果您从mydomain.com发送邮件而您的电子邮件是me@hotmail.com,则应将标题更改为:

From: me@mydomain.com

Reply-To: me@hotmail.com