Asp – Website (asp.net) to send emails via remote mail server, and not end up in spam folders

asp.netlocalhostsmtpclientspam

So, the setup is this, 2 separate servers…

Web server, has IIS7, MS SMTP

Mail server has MailEnable

On the web server, I'm sending an email from an ASP.Net app, via the mail server, and it is getting marked as spam

If I send an email through the mail server, just from a normal mail client, it doesn't get marked as spam.

I'm sure this is a setup issue, but what am I likely to have done wrong?

web.config:

<smtp from="website@domain.co.uk">
  <network host="mail.mymailserver.co.uk" userName="website@domain.co.uk" password="password" />
</smtp>

asp.net, just a normal SmtpClient send:

SmtpClient client = new SmtpClient();
client.Send(mailMessage);

a random gut feeling reckons it's probably sending through the local SMTP server, then on to MailEnable, and that's giving it weird headers…just a thought though

The headers contain this line: Received-SPF: softfail (google.com: best guess record for domain of transitioning website@mydomain.co.uk does not designate unknown as permitted sender)

I've no idea what it means though (the part looks suspicious)

Best Answer

The Received-SPF error is related to Sender Policy Framework. What you need to do is change the DNS records on your domain to include your web server (usually its IP address) as a valid sender.

The SPF website has details on how to setup this configuration.

Edit: It's up to the mail client how to interpret: Received-SPF: softfail. So when you allow any domain to send emails, you might still run into this error. From http://www.openspf.org/SPF_Received_Header:

When an SPF query returns any other result, the MTA should add an advisory header to the message of the form "Received-SPF: neutral" or "Received-SPF: pass". That way, a spam filter further down the road can take that header into account as part of a more balanced decision.

Related Topic