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

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 asp.net pages, both of these send emails out. ASP use CDONTS, and asp.net 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 = "127.0.0.1"  // also have tried without this line, also 'localhost', and the servername setup in the smtp mail server without any success.
    System.Web.Mail.SmtpMail.Send(mail)

Open in new window

   
   
   IIS 6.0 SMTP  Log :
   
    CDONTS GENERATES the following iis6 smtp log when sending out a message successfully :
   
   
    65.55.92.152, OutboundConnectionResponse, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 156, 0, 309, 0, 0, -, -, 220 snt0-mc2-f18.Snt0.hotmail.com Sending unsolicited commercial or bulk e-mail to Microsoft's computer network is prohibited. Other restrictions are found at http://privacy.msn.com/Anti-spam/. Violations will result in use of equipment located in California and other states. Sat, 14 Aug 2010 02:30:35 -0700 ,
    65.55.92.152, OutboundConnectionCommand, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 156, 0, 4, 0, 0, EHLO, -, mail.servername.co.uk,
    65.55.92.152, OutboundConnectionResponse, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 281, 0, 68, 0, 0, -, -, 250-snt0-mc2-f18.Snt0.hotmail.com (3.11.0.113) Hello [109.228.6.149],
    65.55.92.152, OutboundConnectionCommand, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 281, 0, 4, 0, 0, MAIL, -, FROM:<Senders email address> SIZE=551,
    65.55.92.152, OutboundConnectionResponse, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 438, 0, 35, 0, 0, -, -, 250 recipient email address.com....Sender OK,
    65.55.92.152, OutboundConnectionCommand, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 438, 0, 4, 0, 0, RCPT, -, TO:<Recipients email address>,
    65.55.92.152, OutboundConnectionResponse, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 609, 0, 29, 0, 0, -, -, 250 <Recipients email address> ,
    65.55.92.152, OutboundConnectionCommand, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 609, 0, 4, 0, 0, BDAT, -, 551 LAST,
    65.55.92.152, OutboundConnectionResponse, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 1031, 0, 88, 0, 0, -, -, 250  <CP5-2843RSNFqgdyf2I00000001@mail.servername.co.uk> Queued mail for delivery,
    65.55.92.152, OutboundConnectionCommand, 14/08/2010, 10:30:38, SMTPSVC1, CP5-2843, -, 1031, 0, 4, 0, 0, QUIT, -, -,
    65.55.92.152, OutboundConnectionResponse, 14/08/2010, 10:30:39, SMTPSVC1, CP5-2843, -, 1172, 0, 70, 0, 0, -, -, 221 snt0-mc2-f18.Snt0.hotmail.com 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 :
   
    EVENT LOG :
   
    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 !
ByteThoughtsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

meverestCommented:
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.

Cheers/
0
MrHorizontalCommented:
As meverest said, there may be two different problems. To help you find it, MSDN (here: http://msdn.microsoft.com/en-us/library/t7980f5h.aspx) 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("Example:");
         Console.WriteLine("SendMail.exe SomeOne@Contoso.com;SomeOther@Contoso.com Me@contoso.com Hi hello");
      }
   }


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

               try
               {
                  SmtpMail.SmtpServer = "your mail server name goes here";
                  SmtpMail.Send(Message);
               }
               catch(System.Web.HttpException ehttp)
               {
                  Console.WriteLine("{0}", ehttp.Message);
                  Console.WriteLine("Here is the full error message output");
                  Console.Write("{0}", ehttp.ToString());
               }
            }
            catch(IndexOutOfRangeException)
            {
               usage use = new usage();
               use.DisplayUsage();
            }
         }
         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());
         }
      }
   }
}

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Email Servers

From novice to tech pro — start learning today.

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.