Click here to Skip to main content
15,880,503 members
Please Sign up or sign in to vote.
2.69/5 (8 votes)
See more:
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
Updated 22-Aug-17 17:54pm
v2

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
 
Share this answer
 
Comments
Prnda76 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);
Member 11497495 20-Mar-15 3:17am    
// Send Regisration number to user's mail box after submitting the form successfully
SmtpClient smtpc = new SmtpClient("smtp.gmail.com");
smtpc.Port =587;
smtpc.EnableSsl = true;
smtpc.UseDefaultCredentials = false;
string user = "sirikondaswapna@gmail.com"; //<--Enter your gmail id here
string pass = "swapnashankar19";//<--Enter Your gmail password here
string sub = "Form filling Application:"; //Subject for your website
string msg = "Webcome to http://msdotnet.co.in Your Registration Number is: " + Label2.Text; //Message body
smtpc.Credentials = new NetworkCredential(user, pass);
MailMessage email = new MailMessage(user, TextBox6.Text, sub, msg);
email.IsBodyHtml = true;
smtpc.Send(email);

Label1.Text = "Your form has been submitted successfully.Take Preview Now,Your Registration Number is: ";
Label3.Text = null;
There is a from attribute on the smtp element:

http://msdn.microsoft.com/en-us/library/ms164240.aspx[^]

Nick
 
Share this answer
 
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?
 
Share this answer
 
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
 
Share this answer
 
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
 
Share this answer
 
Comments
dineshvishe 3-Jun-13 1:37am    
I am doing For MSSQL Sending mail.Getting error .Any Solution.
I think, you need to check your proxy settings in "internet options". If you are using proxy/'hide ip' applications, this problem may be occurs.
 
Share this answer
 
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900