错误消息用户身份验证错误5.5.1。使用smtp服务器通过asp发送邮件 [英] Error message user authentication error 5.5.1.while sending mail through asp using smtp server

查看:95
本文介绍了错误消息用户身份验证错误5.5.1。使用smtp服务器通过asp发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这上面尝试了几百个代码但是smtp服务器5.5.1.error总是存在。它需要用户身份验证,所以请告诉我如何在smtp中验证用户身份。我的代码如下:



I tried almost hundreds of codes on this but smtp server 5.5.1.error always there. it requires user authentication so please tell me how to authenticate user in smtp. my code is given below:

Imports System.Net.Mail
Imports System.Net

Partial Class Contact
    Inherits System.Web.UI.Page
    Public Property Credentials As ICredentialsByHost

    Protected Sub ok_Click(sender As Object, e As EventArgs) Handles ok.Click

            Dim fromaddr As String = txtemail.Text
            Dim toaddr As String = "Email Address"
        Dim password As String = "Password"

            Dim msg As MailMessage
            Dim smtp As SmtpClient
            Dim nc As NetworkCredential
            msg = New MailMessage()

            msg.Subject = lname.Text
            msg.From = New MailAddress(fromaddr)
            msg.Body = txtquery.Text
            msg.To.Add(New MailAddress(txtemail.Text))
            smtp = New SmtpClient()
            smtp.Credentials = New System.Net.NetworkCredential(fromaddr, password)
        smtp.Host = "smtp.gmail.com"
            smtp.Port = 587
        smtp.UseDefaultCredentials = False
            smtp.EnableSsl = True
        smtp.Send(msg)
        Try
            smtp.Send(msg)
            MsgBox("email sent")
        Catch ex As Exception
            Response.Write("<script>alert('" + ex.ToString() + "');</script>")
        End Try
    End Sub

End Class

推荐答案

解决方案参考:http://how2doinvbdotnet.blogspot.ae/2015/06/send-email-from-gmail-with-smtp.html
Solution Refer : http://how2doinvbdotnet.blogspot.ae/2015/06/send-email-from-gmail-with-smtp.html


这篇关于错误消息用户身份验证错误5.5.1。使用smtp服务器通过asp发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆