I've been working on the MembershipProvider for mojoPortal and trying out the new PasswordRecovery control that hooks into the Membership provider and handles emailing the password depending on whether that is allowed by the settings. In order to use this control you have to have an smtp server configured in your web.config file. Unfortunately its very hard to find information on setting this up correctly and what information I have been able to find with google has been incorrect because apparently things changed in how this is supposed to be done since the beta versions of 2.0 .NET. Even the book I got (Apress Pro ASP.NET 2.0 in C# 2005) has it wrong probably because they were working on the book while 2.0 .NET was still in beta. What the book says and what I mostly found with google was like this: This is apparently how it worked in Beta 1 of 2.0 .NET But in the release version this throws an error: Unrecognized configuration section system.web/smtpMail There was nothing much I could find on MSDN but finally after much googling I found this : Which was apparently the way to do it in Beta 2 of 2.0 .NET but I was getting this error: Unrecognized attribute 'from'. Note that attribute names are case-sensitive But finally after some trial and error I figured out that you have to put the from attribute on the smtp element like this: Hope this helps anyone running into the same problem and unable to find good documentation. You can see for youself that the documentation on MSDN for system.net config section doesn't even mention the mailSettings but this configuration works.
Hi Joe,
I worked on the same section of the book (Password Recovery) this weekend and came up with something similar to what you have.
<configuration> <system.net> <mailSettings> <smtp from=noreply@yourdomain.com> <network host="localhost" port="25" defaultCredentials="true" /> </smtp> </mailSettings> </system.net></configuration>
I've found your article just on time.
Thanks a-lot!
I was having problems with passwordrecovery not finding the smtphost but not anymore!
Thanks for the solution.
Another hapless soul thanking you for saving me untold hours banging my head against this. Thanks!