Emails from my VDS being sent to gmail's spam

Hello Pros,

I have a Virtual dedicated server at . And recently the emails which are sent from domains which are on my VDS are being treated as spam on Gmail. I send them using System.Net.Mail as you can see in the code below. Is there anyway to make the mails so they wont go to spam at gmail? (Yahoo does not send them to span by the way)

Thanks in advance
public bool SendEmail(string strTo, string strFrom, string thebody, string theSubject)
        MailAddress addrFrom = new MailAddress("", "");
        MailAddress addrTo = new MailAddress(strTo);
        MailMessage objMM = new MailMessage(addrFrom, addrTo);

        string bodyToSend;

        bodyToSend = thebody;

        objMM.Subject = theSubject;
        objMM.Body = bodyToSend;
        objMM.IsBodyHtml = true;
        objMM.BodyEncoding = System.Text.Encoding.GetEncoding("UTF-8");

        SmtpClient smtp = new SmtpClient();
        smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;

            return true;
        catch (Exception ex)
            return false;

Open in new window

Who is Participating?
Kamal KhaleefaConnect With a Mentor Information Security SpecialistCommented:
A good tool for this would be

I would recommend that you use a SPF such as "v=spf1 -all" . Please take a look at as this provides a wizard for creating SPF records. You should cross check any SFP you create with the above validation link.

for me i let my domain hosting (the planet)
add it for me
also you have to check for domain keys
Neil RussellTechnical Development LeadCommented:
You need to identify WHY gmail classifies them as spam first.  The code you have posted only sends the email, doesnt tell us anything at all.  
Look at the headers of an email that gmail has put in the spam folder and identify WHY it is spam.
Have you checked that your server is NOT on any blocklists anywhere?
sagirAuthor Commented:
Here is one of the headers of the mails that were sent to spam:

Received: by with SMTP id p11cs34264iba;
        Sun, 22 Aug 2010 11:54:24 -0700 (PDT)
Received: by with SMTP id v1mr5283998ibw.107.1282503264547;
        Sun, 22 Aug 2010 11:54:24 -0700 (PDT)
Return-Path: <>
Received: from ( [])
        by with ESMTP id x7si13266048ibd.70.2010.;
        Sun, 22 Aug 2010 11:54:24 -0700 (PDT)
Received-SPF: neutral ( is neither permitted nor denied by best guess record for domain of client-ip=;
Authentication-Results:; spf=neutral ( is neither permitted nor denied by best guess record for domain of
Message-Id: <>
Received: from [] (helo=VPS-930)
      by with esmtp (Exim 4.63)
      (envelope-from <>)
      id 1OnFgT-00063F-8x
      for; Sun, 22 Aug 2010 14:54:24 -0400
MIME-Version: 1.0
From: <>
Date: 22 Aug 2010 14:54:21 -0400
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64
Subject: =?utf-8?B?c2FnaXJvZGluQGdtYWlsLmNvbSDXqdeS15nXkCwg16nXnNeXINec15og15HXqNeb15Q=?=
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Kamal KhaleefaInformation Security SpecialistCommented:
you have to add SPF Record
ask the domin controller to add it for you

neutral ( is neither permitted nor denied by best guess record for domain of client-ip=;
sagirAuthor Commented:
My domain is controlled in GoDaddy and I have an A-Record pointing to my VDS which is not on GoDaddy. How and where should I set the SPF record (And what should be it's value)?

sagirAuthor Commented:

So on the above example as you can see on the email header, the server from which the email are being sent is . So I should just add it in the ip4 section and that's it?
I get this record generated: v=spf1 ip4: a ~all

and the test result comes back:

Input accepted, querying now...
evaluating v=spf1 ip4: a ~all ...
SPF record passed validation test with pySPF (Python SPF library)!

is this it? just add it on my GoDaddy domain manager and I am done?

Thanks a lot.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.