Click here to Skip to main content
12,694,121 members (34,766 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#3.5
when i am trying to send mail from my web site after uplodind on the web server then server throughs an exception--->"System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"
But when i compaile that code through my computer it works proper.
can any one tell me what to do to solve this problem.
Posted 27-May-11 1:02am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It can be because of various reasons. You need to look at them one by one.
Is the port open? Firewall permissions in place?
Further make sure you have configured SMTP configuration in Web.Config:
      <smtp from="">
        <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />

If needed, have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]
Tutorials on sending Email in ASP.NET[^]
RaviRanjankr 27-May-11 6:26am
Nice Answer, My 5 :)
S Mewara 27-May-11 10:25am
Member 8554498 11-Jan-12 5:34am
Im getting this error on trying to send mail using SMTP with gmail

The email cannot be sentSystem.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at WebApplication3.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Noah Soft\My Documents\Visual Studio 2008\Projects\WebApplication3\WebApplication3\WebForm1.aspx.cs:line 42

mparvez 17-Oct-12 5:04am
Thanks, Atlast I have got my solution from Solution 3 after wasting a lot of time.
Member 8491154 7-Nov-12 2:09am
I am able to send email through the code in one control. But when i use it in some other control it throws "Failure sending email" SmtpException.
Sandeep Mewara 9-Nov-12 1:17am
Can you start a new thread and share your details?
Member 8491154 10-Nov-12 0:52am
It got solved by setting Async property of page to "true"
Sandeep Mewara 10-Nov-12 1:32am
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Are you using McAfee?
By default it blocks port 25.
You Need to change McAfee Settings.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100