Hi

I am trying to create a forgot password section within my login section and it doesnt seem to work.

In my forgotpassword.aspx page my code looks like this:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:PasswordRecovery ID="PasswordRecovery1" runat="server" Height="224px" 
        Width="295px"
        SubmitButtonText="Get Password" SubmitButtonType="Link">
  <MailDefinition From="soccervillage@yahoo.com" 
    Subject="Your new password"
    BodyFileName="PasswordRecovery.txt" />
    </asp:PasswordRecovery>
    
</asp:Content>

In my webconfig page the code looks like this:

<system.net>
  <mailSettings>
   <smtp from="soccervillage@yahoo.com">
    <network host="localhost" password="password" userName="username" />
   </smtp>
  </mailSettings>
 </system.net>

I then have created a text file which is called PasswordRecovery.txt and looks like this:

Your password has been reset, <%UserName%>!

According to our records, you have requested that your password be reset. Your new
password is: <%Password%>

If you have any questions or trouble logging on please contact a site administrator.

Thank you!

The error which I am receiving is:

No connection could be made because the target machine actively refused it ::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 ::1:25

Could anyone help me in this situation?


Thanks

Recommended Answers

All 21 Replies

Could you please provide StackTrace of the exception?

[SocketException (0x274d): No connection could be made because the target machine actively refused it 216.145.54.172: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) +5482743
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.LinkButton.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
System.Web.UI.WebControls.LinkButton.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) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Since your mailbox is hosted on Yahoo! you need to use their host address, instead of localhost. Here you will get the SMTP settings of all popular email service providers.

For Yahoo, the host is: smtp.mail.yahoo.com

However the email I have just made up, does the email have to exist?

Actually I do not have a yahoo email, I have a hotmail. If I am not allowed to make up the email, what should I use for hotmail host?

Yes, the email address should exist. By putting a dummy email address, what you are trying to authenticate?

* Put the proper from address.
* Put appropriate host.
* Supply proper password.

Note: Don't forgot to put the proper To address.

Refer http://www.emailaddressmanager.com/tips/mail-settings.html for SMTP details.

put the proper from address is that the username? And what is the username, the email?


My email is faisal_business@hotmail.co.uk. Could you please state the host name for me?

web.Configu cant send email from localhost

<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="email Address">
<network host="mail server" userName="" password="" <em><strong>port="25"</strong></em> />
</smtp>
</mailSettings>
</system.net>


page.aspx

<asp:PasswordRecovery 
ID="PasswordRecovery1" 
runat="server" 
CssClass="txt" 
ForeColor="Yellow"
GeneralFailureText="" 
QuestionFailureText="" 
SuccessText="" 
UserNameFailureText="">
<MailDefinition 
BodyFileName="<strong><em>PassRecovery.txt</em></strong>" 
From="info@saynacandles.com" 
Priority="High" 
Subject="" 
IsBodyHtml="True">
</MailDefinition>
</asp:PasswordRecovery>


PassRecovery.txt :
<%UserName%>
<%Password%>

In the below code replace YourPassword with your actual password.

<system.net>
	<mailSettings>
		<smtp from="faisal_business@hotmail.co.uk">
			<network host="smtp.live.com" port="25" userName="faisal_business@hotmail.co.uk" password="YourPassword" defaultCredentials="true"/>
		</smtp>
	</mailSettings>
</system.net>

Note: If port 25 has been blocked in your network or by your ISP, you can set SMTP port to 587 with TLS or SSL Encryption depending on the client in use

After making changes too both your replies I still have error. Below is the error which is occuring:

No connection could be made because the target machine actively refused it 65.55.162.200:25

Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 65.55.162.200:25

Stack Trace:

[SocketException (0x274d): No connection could be made because the target machine actively refused it 65.55.162.200: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) +5482743
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

I hope to hear from you soon.

Thank you!

again I say :

U can not Send Mail from Local Host Or MACHINE,

If you look at your smtp settings on the screen shot, it shows the server name, from. And the authentication states the username and password whereas your code which you have provided me with shows something else. Below is the code you provided me with. Could you explain?

<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="email Address">
<network host="mail server" userName="" password="" port="25" />
</smtp>
</mailSettings>
</system.net>

Did you tried using the port 587?

If you look at your smtp settings on the screen shot, it shows the server name, from. And the authentication states the username and password whereas your code which you have provided me with shows something else. Below is the code you provided me with. Could you explain?

<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="email Address">
<network host="mail server" userName="" password="" port="25" />
</smtp>
</mailSettings>
</system.net>

ok

network host is same as server name, usually it's your domain name.
user name and password is for access your mail.
from, is your email address that you sending mail from it.

now i have a question,
are you try to sending mail from local machine?

No I try sending it from University computers

Knvn - No i did not try using that port, should I try that?

your university's computers is mail server?
i think u must try it from a real domain over the internet

If I use mail server the error i receive is:

The remote name could not be resolved: 'mail server'

Exception Details: System.Net.WebException: The remote name could not be resolved: 'mail server'

Stack Trace:


[WebException: The remote name could not be resolved: 'mail server']
System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +5482743
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

That means the computer asked for the IP-address of smtp.yourdomain.xxx at your configurated DNS server and this returned it couldn't find an IP-address for smtp.yourdomain.xxx

So question is: is smtp.yourdomain.xxx a valid address?

Is there a DNS server configured at the computer and has this DNS server a valid DNS entry for smtp.yourdomain.xxx

Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 65.55.162.200:25

Stack Trace:

[SocketException (0x274d): No connection could be made because the target machine actively refused it 65.55.162.200:25]

Some ISP's do block the port 25. This might be the cause for above exception. Just try with the port 587.

Also, try by specifying the below hosts:
64.4.59.173
65.55.37.62

I did not understand that link, I will speak to a tutor maybe find the right host name. Thanks for help anyway!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.