Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
this is the error i encounter....please answer
 

 
No connection could be made because the target machine actively refused it 127.0.0.1:25
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:25
 
Source Error:
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 
Stack Trace:
[SocketException (0x274d): No connection could be made because the target machine actively refused it 127.0.0.1:25]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
   System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224
 
[WebException: Unable to connect to the remote server]
   System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +5421675
   System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +202
   System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21
   System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +332
   System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +160
   System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +159
   System.Net.Mail.SmtpClient.GetConnection() +35
   System.Net.Mail.SmtpClient.Send(MailMessage message) +1213
 
[SmtpException: Failure sending mail.]
   System.Net.Mail.SmtpClient.Send(MailMessage message) +1531
   System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email, String userName, String password, MailDefinition mailDefinition, String defaultSubject, String defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) +367
   System.Web.UI.WebControls.PasswordRecovery.AttemptSendPasswordQuestionView() +522
   System.Web.UI.WebControls.PasswordRecovery.AttemptSendPassword() +69
   System.Web.UI.WebControls.PasswordRecovery.OnBubbleEvent(Object source, EventArgs e) +103
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
 

Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082 
Posted 14-Feb-10 11:27am
adeeeb413
Edited 6-Sep-12 2:31am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

You've specified the host in your web.config as your local machine: 127.0.0.1 is the loopback address.
 
If you don't want to set up an SMTP server on your web server, you'll need the configuration of a public one. A quick google suggests Yahoo uses:
 
host="smtp.mail.yahoo.com"
port="465"
 
Try putting that in your web.config and let us know how you get on.
 
Yahoo may also require SSL and I don't see a way to specify that here:
 
http://msdn.microsoft.com/en-us/library/ms164242.aspx[^]
 
Nick
  Permalink  
Comments
Prnda76 at 23-Feb-13 15:59pm
   
There is EnableSsl property on the SmtpClient class. So in other words, to send mail via Gmail you can use:
 
var client = new SmtpClient
{
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("yourGmailUsername", "yourGmailPassword"),
Host = "smtp.gmail.com"
};
var message = new MailMessage
{
// Setup your MailMessage instance here...
}
client.Send(message);
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 9

There is a from attribute on the smtp element:
 
http://msdn.microsoft.com/en-us/library/ms164240.aspx[^]
 
Nick
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It could be a couple of things.
  1. 127.0.0.1 is the loop back address to your machine, do you have a mail server running on your machine?
  2. Do you have a firewall running and if so is Port 25 open to receive connections?
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Are you setting the SmtpClient.Host property?
 
If this is not the problem, please let us see your code that uses a SmtpClient instance - probably LoginUtil.SendPasswordMail.
 
Nick
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 12

Follow the steps
1. Select the site or Virtual Directory in IIS
2. In Feature View, Right side you see SMTP mail
3. if exists, Click to open a dialogbox
4. Goto Radio button "Store e-mail in pickup directory" enter a valid directory path,
5. Your SMTP starts working, it will not send mails, but all outgoing mail formats you can see, this would be great while debugging, insteading of choking your mail server.
 
Hope it helps,
HydPhani
  Permalink  
Comments
dineshvishe at 3-Jun-13 1:37am
   
I am doing For MSSQL Sending mail.Getting error .Any Solution.

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.140827.1 | Last Updated 24 Sep 2013
Copyright © CodeProject, 1999-2014
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