65.9K
CodeProject is changing. Read more.
Home

Preventing gmail to mark our mails as spam

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.67/5 (3 votes)

Feb 29, 2012

CPOL
viewsIcon

19151

Rencently I've discovered the reason why all the mail messages sent by my Web app were putted on spam folder when the "to" header ends with "@gmail.com". You must include "Message-Id" header or your message will be treated as spam by Google. This is the easy way to do this with System.Net.Mail.MailMessage Class:
Message.Headers.Add("Message-Id", String.Concat("<", Now.ToString("yyMMdd"), ".", Now.ToString("HHmmss"), "@yourdomain.com>" ))
And that's all (obviusly you must follow the Google recommendations too). Wish to save at least the same time that I spent resolving this to many of you.