Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have created a community portal, in which user creates his/her account. After successfull registration a confirmation mail is send on registered email address.

I am using the following code to send the mail -

private void SendMail(string recvr, string recvrName, string verCode, int NewUserID)
{
    try
    {
        string emailID = ConfigurationManager.AppSettings["WebMasterMail"];
        string mailPass = ConfigurationManager.AppSettings["pass"];
        string mailer = ConfigurationManager.AppSettings["mailer"];

        MailMessage msg = new MailMessage();
        MailAddress addrFrom = new MailAddress(emailID, "Panbeli.in.... Bari community portal");
        MailAddress addrTo = new MailAddress(recvr, recvrName);

        msg.To.Add(addrTo);
        msg.From = addrFrom;
        msg.Subject = "You have registered sucessfully on PanBeli.in.";
        msg.Priority = MailPriority.High;
        msg.Body = RegisterMessageBody(recvrName, verCode,NewUserID);
        msg.IsBodyHtml = true;

        SmtpClient smtp = new SmtpClient(mailer);
        smtp.Credentials = new System.Net.NetworkCredential(emailID, mailPass);
        smtp.Send(msg);
    }
    catch (Exception Ex) { }
}

While testing we found that all the confirmation mails are going to SPAM folder instead of Inbox.

Is there anything wrong with the code or is there anything related to security.

Can anybody suggest solution to this problem.

Thanks for sharing your time.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
290 views
Welcome To Ask or Share your Answers For Others

1 Answer

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 xxx@xxx.org 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 xxx@xxx.org 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...