asp.net SMTP服务器要求安全连接或客户端未通过身份验证。服务器响应为:5.5.1需要验证 [英] asp.net The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
问题描述
您好,我知道这个问题有点多余,但我在这里不同的体验它是创造帐户asp.net后发送电子邮件我的code
hi i know this question is a bit redundant but i am experiencing it differently here is my code on sending email after creation of account on asp.net
Dim newreg As MembershipUser = Membership.GetUser(context.Request("username"))
Dim newid As Guid
If newreg.ProviderUserKey IsNot Nothing Then
newid = DirectCast(newreg.ProviderUserKey, Guid)
End If
Dim body As String = String.Empty
Dim reader As StreamReader = New StreamReader(context.Server.MapPath("~/Account/email.htm"))
body = reader.ReadToEnd
body = body.Replace("{UserName}", context.Request("username").ToString)
body = body.Replace("{Url}", "http://wwww.123.com/Account/activate.aspx?id=" & context.Request("username").ToString & "&usertype=" & givetype(context.Request("username")) & "&actid=" & newid.ToString)
Dim mailMessage As MailMessage = New MailMessage
mailMessage.From = New MailAddress(ConfigurationManager.AppSettings("UserName"))
mailMessage.Subject = "Account Activation"
mailMessage.Body = body
mailMessage.IsBodyHtml = True
mailMessage.To.Add(New MailAddress(context.Request("email").ToString))
Dim smtp As SmtpClient = New SmtpClient
smtp.Host = ConfigurationManager.AppSettings("Host")
smtp.EnableSsl = True
Dim NetworkCred As System.Net.NetworkCredential = New System.Net.NetworkCredential
NetworkCred.UserName = ConfigurationManager.AppSettings("UserName")
NetworkCred.Password = ConfigurationManager.AppSettings("Password")
smtp.UseDefaultCredentials = False
smtp.Credentials = NetworkCred
smtp.Port = Integer.Parse(ConfigurationManager.AppSettings("Port"))
smtp.Send(mailMessage)
奇怪的是当我运行在本地主机上的Gmail网站允许,但是当我在一个VPS运行的网站它拒绝并给出了此错误
the odd thing is when i run the website on localhost gmail allows it but when i run the website on a vps it rejects and gives this error
SMTP服务器要求安全连接或客户端未通过身份验证。服务器响应为:5.5.1需要验证
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
任何帮助会做TNX
推荐答案
得到它的工作的问题Gmail是阻止该请求发送电子邮件,因为2步验证我创建的应用程序密码,现在Gmail是不阻断请求发送电子邮件,希望这可以帮助,如果有人会遇到与Gmail相同的问题。
got it working the problem was gmail is blocking the request to send the email because of the 2 step verification i created a password for the app and now gmail is not blocking the request to send e-mails hope this helps if somebody will encounter the same issue with gmail
这篇关于asp.net SMTP服务器要求安全连接或客户端未通过身份验证。服务器响应为:5.5.1需要验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!