Email messages going to spam folder

Emails Marked as Spam

This is not a programming issue unfortunately, but I can understand why you might think it is. The code is sending the emails, and they have been sent as you reported. So this is highly unlikely to be a problem with your code, because it's served it's purpose fully!

Getting around it

It all comes down to the recipients mail client (the software they are using to view the emails with), or the services that process the emails at some sort of gateway, or a combination of both of these!

All of these elements have vastly varied algorithms and metrics for determining if an email is probably spam or not. So a one fit all solution is sadly not possible. Some are intelligent, other less so, some brutally discard a huge % of emails, others operate purely on a 'not on white list, you're not getting in' policy, and then there are those that just let everything come in regardless of content/origin.

The ways to go around fixing this are:

  • To try and get on white lists for major email providers.
  • Educate your audience to add the senders email address as a trusted contact.
  • Check your mail server IP isn't blacklisted by some providers. It's possible your IP address was previously used to send spam.
  • Experiment with the emails content

Your from address is invalid. Try putting in a real email address that points to a valid mailbox. Preferably this email address is on the same domain as the SMTP server you use to send the mail with. If not, read into SPF http://en.wikipedia.org/wiki/Sender_Policy_Framework


It sounds like your email is getting flagged by SpamAssassin or the like, so you just need to focus on changing your email enough to not get flagged.

  • Your content doesn't sound like it has any reason to rate high for the Bayesian score, so I don't think thats the problem. It wouldn't hurt to try removing possible trigger words though.

  • Your message is marked with high priority. Do you need this? This just adds into one of the scoring metrics in a spam filter. Spam is often marked with high priority, so your message will be treated with more scrutiny. On the otherhand, for some filters marking your message with high priority will mean less scrutiny.

  • IsBodyHTML is marked true, but you're only providing text/html. You minimally need to include an alternate view with text/plain.

    message.IsBodyHtml = true;
    string html = RegisterMessageBodyHtml(recvrName, verCode,NewUserID);
    string plain = RegisterMessageBodyPlaintext(recvrName, verCode, NewUserID);
    message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, new ContentType("text/html"));
    message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(plain, new ContentType("text/plain"));
    
  • See how Google treats your message. In gmail, open a test message that you've sent, click the downfacing arrow next to the reply button, and select "Show Original". You'll see how Google treated your message. Look for headers like:

    Received-SPF: softfail (google.com: domain of transitioning [email protected] does not designate xx.xx.xx.xx as permitted sender) client-ip=xx.xx.xx.xx;
    Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning [email protected] does not designate xx.xx.xx.xx as permitted sender) 
    
  • Read up on the default rule set for SpamAssassin as it will probably be a good reference on the rule sets for most filters. If you can identify why your message is getting flagged, you can fix it.

Tags:

C#

Asp.Net