ASP.NET - SmtpClient - Unable to connect to the remote server
<p>I am working on a project where one of the requirements is to re-write an ASP.NET application.  The old ASP.NET application was based on .NET Framework 1.1.  The new ASP.NET application is based on .NET Framework 3.5.</p>

<p>One of the functions in the old web application was the ability to send email.  The old code used the System.Web.Mail.SmtpMail class, whereas the new web application uses the System.Net.Mail.SmtpClient class.</p>

<p>In testing this on our development servers, everything worked fine.  However, we have two beta clients testing out our software, and they both run into problems sending email in the new web application.</p>

<p>The specific exception is as follows:</p>

<p>"Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it"</p>

<p>Both the old and new ASP.NET application are on the same server (Windows Server 2003).  They both are using the same Exchange mail server.  Why is it that the old ASP.NET application can successfully send email, but the new one cannot?</p>

<p>I looked at the old code, and it did not use any form of authentication, it just specified the sender's email address, the recipient's email address, the subject, body, and server, and sent the message.  I did the same thing in the new code, with the only difference being that I used the SmtpClient class.</p>

<p>Please help.</p>

<p>Chris</p>

<p>Below is a code snippet from the new ASP.NET application:</p>

<pre><code>System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(messageTo);
mail.From = new MailAddress(messageFrom);
mail.Subject = messageSubject;
mail.Body = messageBody;
SmtpClient client = new SmtpClient();
client.Host = smtpServer;
client.Send(mail);
</code></pre>
