Search code examples
asp.netemailasp.net-membershippassword-recoverycreateuserwizard

Can asp.net membership controls (PasswordRecovery, CreateUserWizard) be configured to work without SMTP Server?


Our IT staff wants to remove SMTP access from the website layer and have all emails from the website be sent by making a web service call to an internal service which will then send the email directly through an Exchange server.

Is there a way to configure the PasswordRecovery and CreateUserWizard controls to let me send the email directly (by calling the service) instead of having it send automatically using the configured SMTP settings in the web.config?

I don't want to rewrite the pages and use the API directly if I can just configure the controls to work as they are. Otherwise I think I'll have to take out the PasswordRecovery and CreateUserWizard and replace them with my own controls that call into the Membership API.


Solution

  • I found out that CreateUserWizard has an event, OnSendingMail, which can be subscribed to. Setting the MailMessageEventArgs e.Cancel = true causes the email to not be sent by the control but does not cancel the workflow of the wizard. So I cancel the email and send it here without having to rewrite anything.

    PasswordRecovery I had to end up rewriting. Just used the membership API to get the MembershipUser, call ResetPassword(), and send the email with the new password directly.