Wrox Programmer Forums
|
BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9
This is the forum to discuss the Wrox book Professional ASP.NET 3.5: In C# and VB by Bill Evjen, Scott Hanselman, Devin Rader; ISBN: 9780470187579
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 1st, 2010, 11:03 AM
Registered User
 
Join Date: Feb 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Question PasswordRecovery mailbox failure

I have a strange circumstance which someone must have come across before.

I have built a website restricted to registered users. I have use the PasswordRecovery control to allow them to request a new password be emailed to them if they forget it.

This all works fine on the development server.

However, once I have deployed my website to my hosted server I am having problems.

When the user has an email registered on my hosting company's mail server, everything still works OK, but when the control tries to send an email to an external email address (i.e. everybody!) i get the following error:

Quote:
Mailbox unavailable. The server response was: <simon.bowes@btinternet.com> No such user here
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.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: <simon.bowes@btinternet.com> No such user here
my web.config is set up as follows:

<system.net>
<mailSettings>
<smtp>
<network host="mail.survey.juliabowes.com" port="25" userName="admin@survey.juliabowes.com" password="*******" defaultCredentials="false"/>
</smtp>
</mailSettings>
</system.net>

and my PasswordRecovery control is set as:

<asp:PasswordRecovery ID="PasswordRecovery1"
runat="server"
SubmitButtonStyle-CssClass="Button">
<MailDefinition From="FromEmailAddress"
Subject="Your Survey password has been reset">
</MailDefinition>
</asp:PasswordRecovery>




I have spent days arguing with my hosting company that there is a relay problem with their mail server.

However, now I'm convinced that cant be the problem because I can send emails from a regular button control and configuring an email in codebehind as follows:


Imports System.Net.Mail


Dim mm As New MailMessage("FromEmailAddress", "ToEmailAddress")
mm.Subject = "test from survey.juliabowes"
mm.Body = "Hello World"
mm.IsBodyHtml = False

Dim thisSMTP As New SmtpClient

thisSMTP.Send(mm)

With no other code than this, i get an email OK which means that my host providers mail server is relaying the email fine.

The FromEmailAddress is exactly the same as the From in the PasswordRecovery control and the smtp settings can only be coming from Web.config as I havent set them anywhere else.

Therefore this CodeBehind and the PasswordRecovery control must be using the same mechanism for sending the mail.

Can anyone explain why I am having this problem, and what I need to do to set it up correctly?

Otherwise, any ideas for how to make a working version of the control.

Thanks.
 
Old September 1st, 2010, 06:00 PM
Registered User
 
Join Date: Feb 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Thumbs up Partial Solution/Workround

I have found a way round the problem now by forcing a new smtp send using the SendingMail event of the PasswordRecovery control.

Here is my v.simple code which has got round the problem.

Quote:
Protected Sub PasswordRecovery1_SendingMail(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles PasswordRecovery1.SendingMail
Dim thisSMTP As New SmtpClient
thisSMTP.Send(e.Message)
e.Cancel = True
End Sub
This seems to do what I assumed the control was doing anyway, so I'm not exactly sure how this has fixed the problem, but i certainly dont get the error any longer and the email arrives at the destination, so I'm happy (apart from wasting so much time trying to find out what i was doing wrong)





Similar Threads
Thread Thread Starter Forum Replies Last Post
UserName retrival from PasswordRecovery Control varunbwj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 October 9th, 2009 06:56 AM
PasswordRecovery receiving error Specified cast is not valid proffitt711 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 August 21st, 2009 09:01 AM
How to read out a inbox mailbox splanky Pro VB.NET 2002/2003 7 October 18th, 2007 07:14 AM
Read Exchange Mailbox tclancey Pro Visual Basic 2005 4 April 16th, 2007 09:31 AM
Ch16 PasswordRecovery won't email smiller BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 0 October 11th, 2006 03:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.