Web hosting from smarterasp.net. the mail is not sended it shows SMTP server requires a secure connection

Viewed 330

When I used this code to send mail on the visual studio 2012 server (localhost), the mail has been sent successfully. But it shows an authentication problem when I'm free web hosting from smarterasp.net.What problem is going on?

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
  • I expect the mail sending should be successful as on my development server but it shows me ------->

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at

Source Error:

Line 90: Line 91: Line 92: smtp.Send(msg) Line 93: Session("isFromCheck") = "yes"

Source File: h:\root\home\subhankarjana-001\www\alumnifeedback\check.aspx.vb
Line: 92

0 Answers
Related