SMTPMail ( not sending emails out, though CDONTS (asp) is currently working and sending out mails on same server.

Posted on 2010-08-14
Last Modified: 2013-12-18
Hi I am migrating a website from a standalone webserver running windows server 2003/iis 6.0 to a windows server 2008 /iis 7.0.. The website has both asp and pages, both of these send emails out. ASP use CDONTS, and use system.web.mail.smtpmail. This works fine on the current setup but I am having problems getting the system.web.mail.smtpmail to send out any emails on the new 2008 server.

I have set up the smtp default server and can send out emails using cdonts without any problems. However, system.web.mail
simply is refusing to work. i am not getting any error messages as such,

SMTP MAIL SERVER config info :

Access/Authentication set to anonymous access

Relay restrictions Set to restricted to the 2 ip addresses assigned to the server.

delivery - outbound security  - anonymous access

Seems reasonably happy with the settings, since CDONTS is sending out mail fine.

dotNET Code that is not working in current setup, but working in previous server :

Dim mail As New System.Web.Mail.MailMessage()
    mail.From = <From Email Address>
    mail.To = <To Recipient email address>
    mail.Body = "Hope you receive this email sent from dotNET"
    mail.Subject = "Trying to get dotNET to send an email"
    mail.BodyFormat = Web.Mail.MailFormat.Html
    System.web.Mail.SmtpMail.SmtpServer = ""  // also have tried without this line, also 'localhost', and the servername setup in the smtp mail server without any success.

Open in new window

   IIS 6.0 SMTP  Log :
    CDONTS GENERATES the following iis6 smtp log when sending out a message successfully :
  , OutboundConnectionResponse, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 156, 0, 309, 0, 0, -, -, 220 Sending unsolicited commercial or bulk e-mail to Microsoft's computer network is prohibited. Other restrictions are found at Violations will result in use of equipment located in California and other states. Sat, 14 Aug 2010 02:30:35 -0700 ,, OutboundConnectionCommand, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 156, 0, 4, 0, 0, EHLO, -,,, OutboundConnectionResponse, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 281, 0, 68, 0, 0, -, -, ( Hello [],, OutboundConnectionCommand, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 281, 0, 4, 0, 0, MAIL, -, FROM:<Senders email address> SIZE=551,, OutboundConnectionResponse, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 438, 0, 35, 0, 0, -, -, 250 recipient email OK,, OutboundConnectionCommand, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 438, 0, 4, 0, 0, RCPT, -, TO:<Recipients email address>,, OutboundConnectionResponse, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 609, 0, 29, 0, 0, -, -, 250 <Recipients email address> ,, OutboundConnectionCommand, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 609, 0, 4, 0, 0, BDAT, -, 551 LAST,, OutboundConnectionResponse, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 1031, 0, 88, 0, 0, -, -, 250  <> Queued mail for delivery,, OutboundConnectionCommand, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 1031, 0, 4, 0, 0, QUIT, -, -,, OutboundConnectionResponse, 14/08/2010, 10:30:39, SMTPSVC1, CP5-2843, -, 1172, 0, 70, 0, 0, -, -, 221 Service closing transmission channel,
    System.Web.Mail.SMtpmail does NOT generate any IIS SMTP LOG when running the above dotNET code, almost as though it isnt actually using the smtp service !
I am getting two information messages in the event log though when sending out System.web.Mail.SmtpMail, that may (or may not) be relevant :
    1. No usable TLS server certificate for SMTP virtual server instance '1' could be found. TLS will be disabled for this virtual-server.
2. Time spent on preparing to reset routes: [0] milliseconds Time spent on recalculating next hops: [0] milliseconds Queue length : [0].

Please, Please someone help ! Would really be grateful if anyone has any ideas about what this could be, and could help out !

Thanks a lot !
Question by:ByteThoughts
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 37

Expert Comment

ID: 33438825
either smtpMail is not installed properly, or your code throws an exception before it sends - I'd suggest to ass some debug logging to make sure that the application steps through every line, like add a line right after send() to log something to a debug log like 'completed send() ok', etc.


Accepted Solution

MrHorizontal earned 500 total points
ID: 33441186
As meverest said, there may be two different problems. To help you find it, MSDN (here: has a small console program that will catch any exception for you to help you out - copy and paste that in a new console application project and run it on the system with the problems. I've pasted the code below for you too:

using System;
using System.Web.Mail;

namespace SendMail
   class usage
      public void DisplayUsage()
         Console.WriteLine("Usage SendMail.exe <to> <from> <subject> <body>");
         Console.WriteLine("<to> the addresses of the email recipients");
         Console.WriteLine("<from> your email address");
         Console.WriteLine("<subject> subject of your email");
         Console.WriteLine("<body> the text of the email");
         Console.WriteLine("SendMail.exe; Hi hello");

   class Start
      // The main entry point for the application.
      static void Main(string[] args)
               MailMessage Message = new MailMessage();
               Message.To = args[0];
               Message.From = args[1];
               Message.Subject = args[2];
               Message.Body = args[3];

                  SmtpMail.SmtpServer = "your mail server name goes here";
               catch(System.Web.HttpException ehttp)
                  Console.WriteLine("{0}", ehttp.Message);
                  Console.WriteLine("Here is the full error message output");
                  Console.Write("{0}", ehttp.ToString());
               usage use = new usage();
         catch(System.Exception e)
            Console.WriteLine("Unknown Exception occurred {0}", e.Message);
            Console.WriteLine("Here is the Full Message output");
            Console.WriteLine("{0}", e.ToString());


Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question