来自smarterasp.net的Web托管。邮件未发送,表明SMTP服务器需要安全连接

时间:2019-06-20 04:14:47

标签: vb.net smtp

当我使用此代码在Visual Studio 2012服务器(本地主机)上发送邮件时,邮件已成功发送。但是当我从smarterasp.net免费获得网络托管时,它显示了身份验证问题。发生了什么问题?

Private Sub sendCode()

        'email verify
        Dim Random As Random = New Random()
        activationCode = Random.Next(1001, 9999).ToString()

        Session("activationCode") = activationCode

        'email sending
        Dim smtp As SmtpClient = New SmtpClient()
        smtp.Host = "smtp.gmail.com"
        smtp.Port = 587
        smtp.EnableSsl = True
        smtp.UseDefaultCredentials = False
        smtp.Credentials = New NetworkCredential("xyz@xyz.com", "xxxxxxx")

        Dim msg As MailMessage = New MailMessage("xyz@xyz.com", Session("toEmail"), "Activation Code to verify Email Address", "Dear, Alumni your Activation Code is " + activationCode + "\n\n\nThanks & Regards\nVidyasagar University CS Students")

        Try
            smtp.Send(msg)
            lblMessage.Text = "Mail sent successfully"
            Session("isFromCheck") = "yes"
            Response.Redirect("emailVerification.aspx")
        Catch ex As Exception
            lblMessage.Text = ex.Message
        End Try

    End Sub
  • 我希望像在开发服务器上一样成功发送邮件 但它告诉我------->

SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:5.5.1需要身份验证。了解更多 说明:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。

  

异常详细信息:System.Net.Mail.SmtpException:SMTP服务器   需要安全连接或客户端未通过身份验证。的   服务器响应为:5.5.1需要身份验证。了解更多信息

     

源错误:

     

第90行:第91行:第92行:smtp.Send(msg)行   93:Session(“ isFromCheck”)=“是”

     

源文件:   h:\ root \ home \ subhankarjana-001 \ www \ alumnifeedback \ check.aspx.vb
  行:92

0 个答案:

没有答案