C# .NET - Email Sending And Spam problem - Asked By Hamit YILDIRIM on 19-Oct-08 06:20 PM

Hi all;;

Im sending an email to many companies but some of my emails going  to the spam

extirimly on the gmail and yahoo why ?

What can I do??

help me

My q and My R - Hamit YILDIRIM replied to Hamit YILDIRIM on 19-Oct-08 07:47 PM

MailMessage mail = new MailMessage();

mail.To = txtAddress.Text;

mail.From = txtFrom.Text;

mail.Subject = txtsubject.Text;

mail.Body = txtMail.Text;

mail.BodyFormat = MailFormat.Html;

mail.Headers.Add("precedence: bulk", "info@winesturk.com");

mail.Priority = MailPriority.High;

SmtpMail.SmtpServer = txtSmtp.Text;

 

+++++++++++++++++++++++++

  • Use a consistent IP address to send bulk mail.
  • Keep valid reverse DNS records for the IP address(es) from which you send mail, pointing to your domain.
  • Use the same address in the 'From:' header on every bulk mail you send.
  • Through an email asking to subscribe to your list.
  • By manually checking a box on a web form, or within a piece of software.
  • Using an email address list purchased from a third-party.
  • Setting a checkbox on a web form or within a piece of software to subscribe all users by default (requiring users to explicitly opt-out of mailings).
  • A prominent link in the body of an email leading users to a page confirming his or her unsubscription (no input from the user, other than confirmation, should be required).
  • By replying to your email with an unsubscribe request.
  • http://mail.google.com/support/bin/answer.py?hl=en&answer=81126

    thanks all

    re - Web Star replied to Hamit YILDIRIM on 19-Oct-08 11:41 PM

    I recently noticed that automatic mails sent by one of my online shops were flagged as spam when using GMX, GMail or generally mail services which are using SpamAssassin to filter out spam.

    Sending out plain text-mails is old and rusty, if you want to deliver pretty mails to your customers you have to use HTML, unfortunately there is no way around it, but how to make sure that those pretty HTML mails actually reach the customer? Spam filters like SpamAssassin treat HTML Mails as potentially dangerous, so you have to use HTML very carefully.

    If you do use HTML Mails you have to create two kinds of Bodys, one HTML Mail Body and one PlainText Mail Body. I show you how to do this in C# / ASP.NET 2.0 by using the built-in System.Net.Mail Class after some general advices.

    Here are some recommendations for a automatic HTML mails which are being sent out a hundred times per day:

    • Don’t forget to add <html><body>Your HTML Text/Code</body></html> to your HTML-Text-String
    • Try to stick with 1-3 Images in total. For example your Logo, a header background and a photo of the particular product.
    • Use HTML Tags with care. Set a good looking font like Arial, create listings, link tags, bold and italic texts and restrict yourself to create a well formed/layouted text, which is most important. Don’t even think about implenting an embed or object tag for including flash videos or anything like that.

    SpamAssassin checks a lot of factors and is using a point-system for filtering out spam, here is a little snippet:

    1.723 MSGID_FROM_MTA_ID
    0.001 HTML_MESSAGE
    5.000 BAYES_99
    0.177 MIME_HTML_ONLY
    1.047 HTML_IMAGE_ONLY_16
    0.629 FORGED_OUTLOOK_HTML

    The heaviest impact is BAYES_99, if your text sounds spammy, you are spam flagged. If you e.g. sell Viagra you shouldn’t list the product name in your confirmation mail ;-). Another example is MIME_HTML_ONLY, this hits your mail if you only supply HTML Text, without a seperated PlainText. I won’t explain every function in detail here, if you follow this HowTo you likely won’t run into any problems.

    Let’s have a look on how to properly send a HTML Mail with the System.Net.Mail Class, in this case it is sending the Mail via Google Apps / GMail:

    public void ExecuteHtmlSendMail(string FromAddress, string ToAddress, string BodyText, string Subject)
    {
    MailMessage mailMsg = new MailMessage();

    mailMsg.From = new MailAddress(FromAddress);
    mailMsg.To.Add(new MailAddress(ToAddress));
    mailMsg.Subject = Subject;
    mailMsg.BodyEncoding = System.Text.Encoding.GetEncoding(”utf-8″);

    System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString
    (System.Text.RegularExpressions.Regex.Replace(BodyText, @”<(.|\n)*?>”, string.Empty), null, “text/plain”);
    System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(BodyText, null, “text/html”);

    mailMsg.AlternateViews.Add(plainView);
    mailMsg.AlternateViews.Add(htmlView);

    // Smtp configuration
    SmtpClient smtp = new SmtpClient();
    smtp.Host = “smtp.gmail.com”;

    smtp.Credentials = new System.Net.NetworkCredential(”username”, “password”);
    smtp.EnableSsl = true;

    smtp.Send(mailMsg);
    }

    What’s important here: Setting the correct Encoding, in my case utf-8. Create a plainView and htmlView of the mail message. For the plainView I used a simple Regex statement for stripping out the HTML Tags. Add the plainView and htmlView to the AlternateViews Class of the Mail Message and finally send the mail, in my case via SSL, if you don’t know whether you have an Mailserver with SSL capabilities just ask your provider.

    Using this construct you send out your HTML Mails as HTML Mail and Plaintext Mail and SpamAssassin is going to like you for that.

    I use gmx.net for testing my mails as they are using a pretty well configured SpamAssassin and you can easily see the spam-flags by checking out the Header of the mail (also possible with GMail and hopefully every other mail application out there). An example of this:

    X-GMX-Antispam: 5 (HTML_IMAGE_ONLY_12,HTML_MESSAGE,HTML_MIME_NO_HTML_TAG,MIME_HTML_ONLY)
    X-GMX-UID: UNbaLmk4ZDI4zQ9QSmY2gY1xemhmY8Gs

    A Spam-Score of 5 (=treated as Spam) and it’s telling me that I didn’t supply a PlainText Version of the Mail, after including that one all errors were gone.

    re - Web Star replied to Hamit YILDIRIM on 19-Oct-08 11:45 PM

    There are so many reasons your email can goes to spam folder
    some are
    1. you send bulk email and one of the yahoo recipient marked it as spam all yahoo recipient will receive that email in spam folder
    2. your ISP marked it as spam due to duplicate contain
    3. sender domain not matched with the IP address
    4. duplicate post etc.. .
    5. your domain IP is in black list

    change your mail.Priority to High

    Dim objMail As New System.Web.Mail.MailMessage()
    objMail.BodyFormat = MailFormat.Html
    objMail.From = "test@gmail.com"
    objMail.[To] = "test@gmail.com"
    objMail.Subject = "Test Information"
    objMail.Priority = System.Web.Mail.MailPriority.High
    Dim l_body As String
    l_body = "<br/>" + "This is Test"
    objMail.Body = l_body
    SmtpMail.Send(objMail)

    Whenever i send any email from C#.net, all of them land up in spam - C_A P replied to Hamit YILDIRIM on 20-Oct-08 02:16 AM
    Not sure why that is happening. My guess is this has more to do with your email client rather than your C# code. You might try using all valid email addresses (ie, in the "to" and "from" of the email). On the client side, there could be any number of things flagging the email as spam. Once you get one of the emails in your spam folder, mark it as "not spam" if your email client offers that option. Also, add the "from" address of your email to your client's safe senders list (ie, the list it recognizes as valid email addresses). You might also try filling in more realistic data into your email (ie, put "how are you doing" into your message body instead of "no spam"). Basically, make the email look like a real email so your client doesn't think it's not. I also find it a bit suspect that "smtpmail.Host" is set to "localhost". Perhaps your client doesn't recognize this host (ie, your computer) and is flagging the email as spam. I'm not sure if you are supposed to set it to something other than "localhost", but it was the only thing that really jumped out at me. Let me know if you are able to figure this one out.
    thanks - Hamit YILDIRIM replied to Web Star on 20-Oct-08 08:08 AM
    thanks
    thanks - Hamit YILDIRIM replied to C_A P on 20-Oct-08 08:09 AM
    thanks
    slm - Hamit YILDIRIM replied to özkan hamit on 08-Jul-09 03:32 AM
    Özgür bey bu sorunun cevabı sizinde gördüğünüz gibi 1 tane değil.
    ama sırayla yapılması gerekiyor. Bunlardan en önemlileri;

    1- gmail için email'in güvenli olduğuna dair bazı işaretleri koymak gerekiyor. Hatta bu artık standart haline geldi sanırım diğer sitelerde yahoo gibi gerektirmeye başladı. Bu gereksinimler yukarıda benim ilk yazıtlarımın içersinde yazıyor. Mailin okunup okunmadığını kullanıcıya soran bir HyperText ve ondan cevap alan bir option veya checkbox'ın gönderilen mail sayfasında olması lazım.
    2- Mail Gönderme zaman aralıklarının belli bir düzende olmaMAsı gerekiyor
    başka gereksinimler de var şu an hepsi aklımda değil ama evet yaptık istediğimiz oldu

    Gmail'in bununla ilgili requirements'ını okuyun yaklaşık 10 madde size yardımcı olur.
    Kolay gelsin,

    Teşekkürler