asp.net - Why is my VB.NET website not sending an email? -
my code adding user database. trying have site send email passcode verify email account legit.
first trying send basic test email. plan on adding passcode in link site validating it.
my problem code doesn't send basic test email.
imports system.data.sqlclient imports system.net.mail partial class account_register inherits system.web.ui.page protected sub page_load(byval sender object, byval e system.eventargs) handles me.load registeruser.continuedestinationpageurl = request.querystring("returnurl") end sub protected sub registeruser_createduser(byval sender object, byval e eventargs) handles registeruser.createduser formsauthentication.setauthcookie(registeruser.username, false) dim mymailmessage new mailmessage() ' mymailmessage.isbodyhtml = true mymailmessage.from = new mailaddress("name@gmail.com") mymailmessage.to.add("name@yahoo.com") mymailmessage.subject = "email confirmation" mymailmessage.body = "testing" 'mymailmessage.body = "<html>" & registeruser.username & "link: $" & "<br/> " & "</html>" 'create smtpclient object , specify smtp gmail server dim smtpserver new smtpclient("smtp.gmail.com") smtpserver.port = 588 smtpserver.credentials = new system.net.networkcredential("name@gmail.com", "password") smtpserver.enablessl = true try smtpserver.send(mymailmessage) 'messagebox.show("email sent") catch ex smtpexception 'messagebox.show(ex.message) end try dim continueurl string = registeruser.continuedestinationpageurl if string.isnullorempty(continueurl) continueurl = "~/" end if response.redirect(continueurl) end sub end class
any help?
change port number gmail smtp port : 465
use this
smtpserver.port = 465
Comments
Post a Comment