ASP.NET CreateUserWizard Override SendingMail Event

Recently I had an issue where I needed to call another email method and not use the STMP settings in the Wizard Control. 

I send an email to have the user verify their account using the CreateUserWizard SendingEmail Event. This works great by using the email setup in the control.



In order to override the send email event I issued a return statement in the SendingMail event handler.

protected void CreateUserWizard1_SendingMail(object sender, MailMessageEventArgs e)
{
return; . . .

Next I created an event after the user was created using oncreateduser="CreateUserWizard1_CreatedUser"

Now in the CreateUserWizard1_CreatedUser method I send the registration email to the new user.

 protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
OverideWizardEmail();
}  

private void OverideWizardEmail()
{ 
MembershipUser UserInfo = Membership.GetUser(CreateUserWizard1.UserName);
string VerifyURL = string.Empty;
..... send email

Relay Email From GoDaddy VPS

If you have hosted a website in GoDaddy's shared environment you were probably used smtp.secureserver.net to send emails through a relay.

On a VPS slice you cannot use smtp.secureserver.net since port 25 will be blocked.  You do not want to use any email accounts as it will cause you to hit a 250 send limit per account. A relay is the answer and your VPS must be setup to use one.

In order to send you first need to get the VPS relay smtp server name from GoDaddy. It may be different depending upon the IP address of your VPS.

By default IIS 6 is not installed on the VPS Slice. You will need to install IIS 6 first.

After installing IIS 6 click on the properties of the SMTP Server and the Delivery Tab, then click on Advanced.

 

On the Advanced tab setup your server name and specify the SMTP relay as shown below.  Verify the relay name with GoDaddy. This one may work for you but better safe then sending emails into vapor-land. 

Once you have this setup use localhost in your application as the relay.  You do not need so specify a password, just connect with a valid email address used for your domain.

Here is an ASP.NET web.config example

<system.net>
  <mailSettings>
   <smtp from="youremail@yourdomain.com">
    <network host="localhost" />
   </smtp>
  </mailSettings>
 </system.net>

Modal