Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2010-08-14
3
Medium Priority
?
1,853 Views
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 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 !
0
Comment
Question by:ByteThoughts
2 Comments
 
LVL 37

Expert Comment

by:meverest
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.

Cheers/
0
 
LVL 3

Accepted Solution

by:
MrHorizontal earned 2000 total points
ID: 33441186
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The new Gmail Phishing Scam going around is surprising even the savviest of users with its sophisticated techniques.
Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

580 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