所有电子邮件都使用phpmailer发送到GMail,Hotmail和其他电子邮件提供商的垃圾邮件文件夹 [英] All E-mails goes to spam folder of GMail, Hotmail and other email providers using phpmailer

查看:101
本文介绍了所有电子邮件都使用phpmailer发送到GMail,Hotmail和其他电子邮件提供商的垃圾邮件文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我发送电子邮件与 PHP Mailer 函数有问题。我从我的脚本发送的每封邮件都是直接转到GMail,HotMail和其他邮件提供商的垃圾邮件文件夹。



我已经配置了我的域名,密码等...



这是我的PHP代码:

  $ message = 
< html>
< head>
< title>激活< / title>
< / head>
< body>
< p> Hello moorthi< / p>
< p>感谢您使用我的邮件服务< b>< a href ='http://www.mobilebeez.co.in/' > mobileBeez< / a>< / b>< / p>< br />

< p>< b> mobileBeez技术< b>< br> ,印度。< / p>
< p>< a href ='https://www.facebook.com/mobileBeez'> https://www.facebook.com/mobileBeez< / a> ;< / p>
< / body>
< / html>
;

$ mail = new PHPMailer(); //创建一个新对象
$ mail-> IsSMTP(); //启用SMTP
$ mail-> Host =vps.vendarcorporates.com;
$ mail-> SMTPDebug = 1; // debugging:1 = errors and messages,2 = messages only
$ mail-> SMTPAuth = true; // authentication enabled
$ mail-> SMTPSecure ='ssl'; //安全传输启用要求GMail
$ mail-> Port = 465;
$ mail-> IsHTML(true);
$ mail-> Username =info@vendarcorporates.com;
$ mail-> Password =***************;
$ mail-> SetFrom(info@vendarcorporates.com);
$ mail-> FromName =mobile Beez;
$ mail-> AddReplyTo(info@vendarcorporates.com,手机贝司);
$ mail-> Subject =激活您的帐户;
$ mail-> Body = $ message;
$ mail-> AddAddress(moorthi@gmail.com); //要解决
if($ mail-> Send()){
print json_encode(SUCCESS);
}
else {
echoMailer Error:。 $ MAIL-> ERRORINFO;
}

我的结果像 SUCCESS 这意味着邮件成功发送,但是当我检查我的GMail时,我发送的邮件是在SPAM文件夹中。



在我的服务器上这是邮件配置

 安全SSL / TLS设置(推荐)
用户名:info@vendarcorporates.com
密码:使用电子邮件帐户的密码。
传入服务器:vps.vendarcorporates.com

IMAP端口:993
POP3端口:995
发送服务器:vps.vendarcorporates.com

SMTP端口:465
IMAP,POP3和SMTP需要验证。


解决方案


使用 PHP Mailer
函数发送电子邮件时出现问题。我从我的脚本发送的每封邮件都是直接的方式是
到Gmail,Hotmail和其他邮件提供商的垃圾邮件文件夹。


这个问题与PHP Mailer,你的代码甚至你的主机无关。但是它与您的主机名称&甚至IP地址。当你这样说:


我得到的结果像 SUCCESS 这意味着邮件已成功发送
但是当我查看我的GMail时,我发送的邮件是在SPAM文件夹中。


正确您的邮件实际上是由服务器发送的。哪个是好的但接收端的邮件服务器不知何故不信任您的主机名或IP地址。可以做一些事情来弥补这一点。如您的主机名的DNS&为正在发送实际电子邮件的服务器的IP地址设置一个PTR(反向DNS)记录。



最重要的是,一个实际的域名是 vendarcorporates.com 做一个ping它这个全球性的工具显示一致的未知主机:vendarcorporates.com 结果。如果是这样的话您正在尝试发送,那里有你的问题。



就SPF记录而言,这是一个DNS记录,意味着发件人策略框架翻译成基本意义:您,由于主机名的所有者允许这些其他IP地址&代表您发送电子邮件的主机名。更多此处的详细信息,具体如下:


更准确地说,SPFv1允许域的所有者指定
他们的邮件发送策略,例如他们使用哪些邮件服务器从他们的域发送
邮件。该技术要求双方一起玩
(1)域名所有者在域的DNS区域中的SPF
记录中发布此信息,并且当其他人的邮件服务器
收到声称来自该域的消息,然后(2)
接收服务器可以检查
消息是否符合
域的规定策略。如果信息来自未知的
服务器,那么它可以被认为是假的。


设置它是在您的DNS中设置一个TXT(文本)记录,如下所示:

 v = spf1 ip4 :123.45.67.890〜all

假设您的域名为 vendarcorporates.com ,这样的SPF记录将在接收端执行如下操作:




  • 嘿,我刚收到一个e声称是 vendarcorporates.com 的人的邮件信息

  • 连接到此邮件的IP地址是否直接属于 vendarcorporates.com

  • 如果是连接到 vendarcorporates.com 的I​​P地址,那么一切都很好!

  • 但这个IP地址是 123.45.67.890 ,它没有连接到 vendarcorporates。 COM 。好吧,我正在阅读SPF记录,而 123.45.67.890 可以发送电子邮件, c code code code code code code code code $ c $这可能不能完全解决问题。所以除了一个SPF记录,你需要确保你的服务器有一个有效的PTR(反向DNS)记录,在某种程度上匹配你的主机名。



    不像DNS记录主机名转换为IP地址的位置,PTR记录是将IP地址转换为主机的反向DNS记录。更多维基百科上的信息



    如何您可以设置PTR取决于您的主机的工作方式。




    • 有些放置像RackSpace允许客户自己设置PTR记录。

    • 像Amazon AWS这样的其他人可以请求一个PTR记录,但需要批准它。

    • 其他许多人根本不会让你自己设置一个PTR记录。您需要联系您的托管服务请求他们为您设置PTR记录。



    PTR记录重要的原因是是这样垃圾邮件?链。所以它会播放如下:




    • 嘿,我刚刚收到一个声称是$ code的人的电子邮件> vendarcorporates.com !

    • 连接到此消息的IP地址是否直接属于 vendarcorporates.com



    第二步,检查邮件的IP地址是否连接到 vendarcorporates.com ?这是PTR记录检查。



    我相信有两个SPF和您的域名&主持人将清除这个问题。



    外面的机会,你有一个SPF& PTR记录集邮件最终在垃圾邮件中?那么这意味着你的主机名和/或IP地址被列入黑名单。那是一个完整的蠕虫病毒,可以让你处理。您可以使用在线工具(如 MX Toolbox &遵循个性化服务建议请求您被删除。但是,根据您在此列表中排名的严重程度,这可能是一个简单的任务或非常复杂的任务。



    Mailer可以轻松发送电子邮件的过程,确保您的电子邮件的整个过程没有被标记为垃圾邮件是一个与编码细节无关的其他谚语的野兽。


    Recently I have a problem on sending e-mail with PHP Mailer function. Every mail which I sent from my script is straight way goes to spam folder on GMail, HotMail and other mail providers.

    I have configured everythig with my domain name, password etc…

    Here is my PHP code:

    $message = "
    <html>
    <head>
      <title>Activation</title>
    </head>
    <body>
    <p>Hello moorthi , </p>
    <p>Thank you for Using My Mail Service <b><a href='http://www.mobilebeez.co.in/'>mobileBeez </a></b></p><br/>
    
    <p><b>mobileBeez Technologies<b><br>Chennai, India.</p>
    <p><a href='https://www.facebook.com/mobileBeez'>https://www.facebook.com/mobileBeez</a></p>
    </body>
    </html>
    ";
    
    $mail = new PHPMailer(); // create a new object
    $mail->IsSMTP(); // enable SMTP
    $mail->Host = "vps.vendarcorporates.com";
    $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Port = 465; 
    $mail->IsHTML(true);
    $mail->Username = "info@vendarcorporates.com";
    $mail->Password = "***************";
    $mail->SetFrom("info@vendarcorporates.com");
    $mail->FromName   = "mobile Beez";
    $mail->AddReplyTo("info@vendarcorporates.com","mobile Beez");
    $mail->Subject = "Activate your Account";
    $mail->Body = $message;
    $mail->AddAddress("moorthi@gmail.com"); // To Address
    if($mail->Send()) {
      print json_encode("SUCCESS");
    }
    else {
      echo "Mailer Error: " . $mail->ErrorInfo;
    }
    

    And I got result like SUCCESS which means "Mail Successfully Sent." But when I check on my GMail the mail which I sent is on SPAM folder.

    On my server this is the mail configuration

    Secure SSL/TLS Settings (Recommended)
    Username:   info@vendarcorporates.com
    Password:    Use the email account’s password.
    Incoming Server:    vps.vendarcorporates.com
    
                            IMAP Port: 993
                            POP3 Port: 995
    Outgoing Server:    vps.vendarcorporates.com
    
                            SMTP Port: 465
    Authentication is required for IMAP, POP3, and SMTP.
    

    解决方案

    Recently I have a problem on sending e-mail with PHP Mailer function. Every mail which I sent from my script is straight way goes to spam folder on GMail, HotMail and other mail providers.

    The issue has nothing to do with PHP Mailer, your code or even your host. But it has to do with overall outgoing mail settings on your hostname & even IP address. Meaning when you say this:

    And I got result like SUCCESS which means "Mail Successfully Sent." But when I check on my GMail the mail which I sent is on SPAM folder.

    Correct, your mail was actually sent by the server. Which is good. But the mail servers on the receiving end somehow do not trust your hostname or IP address. A few things can be done to remedy this. Such as setting and SFP record in your hostname’s DNS & setting a PTR (reverse DNS) record for the IP address of the server that is sending out the actual e-mails.

    First & foremost, is vendarcorporates.com an actual domain? Doing a ping for it on this tool that pings globally shows consistent Unknown host: vendarcorporates.com results. If that is the case & you are trying to send with that, there is your problem right there.

    As far as SPF records go, that is a DNS record that means "Sender Policy Framework" which translates to basically meaning: You, as the owner of a hostname allow these other IP addresses & hostnames to send e-mail on your behalf. More details here specifically this:

    Even more precisely, SPFv1 allows the owner of a domain to specify their mail sending policy, e.g. which mail servers they use to send mail from their domain. The technology requires two sides to play together: (1) the domain owner publishes this information in an SPF record in the domain's DNS zone, and when someone else's mail server receives a message claiming to come from that domain, then (2) the receiving server can check whether the message complies with the domain's stated policy. If, e.g., the message comes from an unknown server, it can be considered a fake.

    The way you would set this up is to set up a TXT (text) record in your DNS with something like this:

    "v=spf1 ip4:123.45.67.890 ~all"
    

    Assuming your domain is vendarcorporates.com, an SPF record like this would work as follows on the receiving end:

    • Hey, I just received an e-mail message from someone claiming to be vendarcorporates.com!
    • Does the IP address connected to this message directly belong to vendarcorporates.com?
    • If it is an IP address connected to vendarcorporates.com, then all good!
    • But this IP address is 123.45.67.890 and it is not connected to vendarcorporates.com. So let’s check the SPF record.
    • Okay, I am reading the SPF record, and 123.45.67.890 is allowed to send e-mails for vendarcorporates.com, so let’s let this message through.

    Now that might not completely solve the issue. So in addition to an SPF record, you need to make sure your server has a valid PTR (reverse DNS) record that in some way matches your hostname.

    Unlike a DNS record where a hostname is translated to an IP address, a PTR record is a reverse DNS record where an IP address is translated into a hostame. More info on Wikipedia.

    How you can set a PTR is dependent on the way your host works.

    • Some placed like RackSpace allow customers to set PTR records on their own.
    • Others like Amazon AWS will allow you to request a PTR record, but they need to approve it.
    • And many others simply will not let you set a PTR record on your own. You need to contact your hosting service & ask them to setup a PTR record for you.

    The reason PTR records are important is it is yet another check in the "Is this SPAM?" chain. So it would play out like this:

    • Hey, I just received an e-mail message from someone claiming to be vendarcorporates.com!
    • Does the IP address connected to this message directly belong to vendarcorporates.com?

    That second step where there is a check to see if an IP address of a mail is connected to vendarcorporates.com? That is the PTR record check.

    I’m fairly confident that having both the SPF & PTR record for your domain name & host set will clear up this issue.

    And on the outside chance that you do have an SPF & PTR record set yet e-mails end up in SPAM? Well, that means your hostname and/or IP address is blacklisted. And that is a whole other can of worms for you to deal with. You can check your blacklist status with an online tool like MX Toolbox & follow individual service recommendations to request you be removed. But depending on the severity of your ranking in this list, this could either be a simple task or a very complex one.

    Which is all to say, while tools like PHP Mailer ease the process of sending e-mails, the whole process of ensuring your e-mails are not tagged as SPAM is a whole other proverbial beast that has little to do with coding specifics.

    这篇关于所有电子邮件都使用phpmailer发送到GMail,Hotmail和其他电子邮件提供商的垃圾邮件文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆