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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Easy CSR creation in Exchange 2007,2010 and 2013
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

774 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