Click here to Skip to main content
11,642,658 members (65,969 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.5
when i am trying to send mail from my asp.net 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 209.173.141.250:25"
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 0:02am
Rate this: bad
good
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:
 <system.net>
    <mailSettings>
      <smtp from="abc@somedomain.com">
        <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
      </smtp>
    </mailSettings>
 </system.net>
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[^]
  Permalink  
Comments
RaviRanjankr at 27-May-11 6:26am
   
Nice Answer, My 5 :)
S Mewara at 27-May-11 10:25am
   
Thanks.
Member 8554498 at 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 74.125.127.108:25 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



CAN ANY1 HELP THIS
mparvez at 17-Oct-12 5:04am
   
Thanks, Atlast I have got my solution from Solution 3 after wasting a lot of time.
Member 8491154 at 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 at 9-Nov-12 1:17am
   
Can you start a new thread and share your details?
Member 8491154 at 10-Nov-12 0:52am
   
It got solved by setting Async property of page to "true"
Sandeep Mewara at 10-Nov-12 1:32am
   
Ok.
Rate this: bad
good
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.
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.150731.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2015
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