Email sent from web server causes gmail to treat as phishing. How to get rid of this?

情到浓时终转凉″ 提交于 2019-12-06 08:02:27

问题


I am sending account activation email from my .net app.

I set the from address to "xyz.support@gmail.com" and from name "xyz" where xyz is the name of the domain i.e. our website.

It was not a problem when we were using Google's SMTP server as I provided credentials to google during sending. But now I am using my own web server's SMTP to send the email.

When I view the activation email in gmail, I get this:

This message may not have been sent by: xyz.support@gmail.com Learn more Report phishing

Is there a way to get rid of this so that gmail and other client don't show this message?

Here is the code:

var smtpClient = new SmtpClient();
var message = new MailMessage();

smtpClient.Host = _config.SMTPServer;
message.From = new MailAddress("xyz.support@gmail.com", "xyz");
message.To.Add("newuser@gmail.com");            

message.IsBodyHtml = true;
message.Subject = "Test subject";
message.Body = "Test Body";

smtpClient.Send(message);

Thanks


回答1:


The domain of the FROM address has to match the domain of the SMTP server that is sending the email, otherwise your message is treated as as spam.

This explains why you avoid the "error" by sending via Google's SMTP server.




回答2:


The suggestion by IrishChieftain to use SPF helped me, so here is a summary of the steps I did:

1.) First, I also received emails in my GMail inbox that I sent from my sever and that got the "This message may not have been sent by..." warning.

2.) Next, I looked at the source of the email inside GMail (clicke the arrow next to the message and select "Display original"). An excerpt from there was:

Received-SPF: fail (google.com: domain of me@mydomain.com does not designate 211.113.37.19 as permitted sender) client-ip=211.113.37.19;

So Google directly told me what to do: Add some SPF records in the DNS of my domain "mydomain.com" to get rid of this warning.

3.) Therefore I logged into the control panel of my DNS provider and added two TXT records, something like this:

*.mydomain.com. 180 v=spf1 +a +mx ip4:211.113.37.19 -all
mydomain.com. 180 v=spf1 +a +mx ip4:211.113.37.19 -all

Please note that I entered each line in three separate fields:

  • One field for *.mydomain.com.
  • One field for 180 (the TTL, 3 minutes in my example)
  • One field for v=spf1 +a +mx ip4:211.113.37.19 -all

4.) After that, I waited some time and tried to resend. This succeeded. Google now shows in the original:

Received-SPF: pass (google.com: domain of Received-SPF: pass (google.com: domain of me@mydomain.com designates 211.113.37.19 as permitted sender) client-ip=211.113.37.19;

Please note that I choose the SPF version since the mail server is on a different machine as the web server, so I could not perform the other solution as Mulmot wrote.

There is also an SPF Wizard from Microsoft to correctly generate SPF records. Alternatively, here is yet another SPF generator.



来源:https://stackoverflow.com/questions/10378814/email-sent-from-web-server-causes-gmail-to-treat-as-phishing-how-to-get-rid-of

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!