Problems sending email using .Net’s SmtpClient

emailsmtp

I've been looking through questions on Stackoverflow and Serverfault but haven't found the same problem mentioned – though that may be because I just don't know enough about how email works to understand that some of the questions are really the same as mine … here's my situation:

I have a web application that uses .Net's SmtpClient to send email. The configuration of the SmtpClient uses a smtp server, username and password. The SmtpClient code executes on a server that has an ip address not in the domain the smtp server is in.

In most cases the emails go without a problem – but not AOL (and maybe others – but that is one we know for sure right now).

When I look at the headers in the message that was kicked back from AOL it has one less line than the successful messages hotmail gets:

AOL Bad Message:

Received: from WEBSVRNAME ([##.###.###.###]) by domainofsmtp.com with MailEnable ESMTP; Mon, 18 Jun 2012 09:48:24 -0500
MIME-Version: 1.0
From: "donotreply@domainofsmtp.com" <donotreply@domainofsmtp.com>
...

Good Hotmail Message:

Received: from mail.domainofsmtp.com ([###.###.###.###]) by subdomainsof.hotmail.com with Microsoft SMTPSVC(6.0.3790.4900); Thu, 21 Jun 2012 09:29:13 -0700
Received: from WEBSVRNAME ([##.###.###.###]) by domainofsmtp.com with MailEnable ESMTP; Thu, 21 Jun 2012 11:29:03 -0500
MIME-Version: 1.0
From: "donotreply@domainofsmtp.com" <donotreply@domainofsmtp.com>
...

Notice the hotmail message headers has an additional line.

I'm confused as to why the Web server's name and ip address are even in the headers since I thought I was using the SmtpClient to go through the smtp server (hence the need for the username and password of a valid email box).

I've read about SPFs, DKIM and SenderID's but at this point I'm not sure if I would need to do something with the web server (and its ip/domain) or the domain the smtp is coming from. Has anyone had to do anything similiar before?

Am I using the smtp server as a relay? Any help on how to describe what I'm doing would also help.

Best Answer

Here are some things you can do to troubleshoot your issue with AOL and others:

First, know that AOL, and others, use methods to prevent spam such as refusing email from email domains that do not have a reverse lookup record, graylisting or by using SPF records. You should check each of these. The graylisting one would return an error when smtpclient send method is executed.

Next, if you can check the server that is executing the send method to see if it is throwing any errors or if errors are being ignored in a try catch block.

Also, you can telnet to your SMTP server and do an EHLO test to see if you can view any problems.

See more information on AOL blocking policy here: http://postmaster.aol.com/Postmaster.Errors.php

Other email domains may use similar methods to prevent spam so you may need to follow the same troubleshooting with those as well.