Sending mail with CreateUserWizard
I tried sending mail with the CreateUserWizard. My SMTP server needs authentication, which I declared in the web.config.
Here is the code (I removed the password):
<network host="mail.avidan.co.il" password="XXXXX" userName="firstname.lastname@example.org" port="2525" defaultCredentials="true" />
It didn't work, I got an yellow error page (server needs authentication etc etc).
I added then the following code in the CreateUserWizard1_SendingMail prcoedure:
Dim mysmtpclient As SmtpClient = New SmtpClient("mail.avidan.co.il")
mysmtpclient.Port = "2525"
mysmtpclient.Credentials = New System.Net.NetworkCredential("email@example.com" , "xxxxx")
e.Cancel = True
Now it's working! Why did I have to add the code in the CreateUserWizard1_SendingMail procedure? I thought putting the code in the web.config is enough.