[英]The SMTP server requires a secure connection or the client was not authenticated in C# ASP.NET
I am trying to send an email but i am getting authentication failure. 我正在尝试发送电子邮件,但身份验证失败。
Do we need any specific type of authentication for Google mail. 我们是否需要任何特定类型的Google邮件身份验证。
[Error in Browser][1]
// Created Mail message and taken inputs
MailMessage mail = new MailMessage(from,to,subject,message);
// Used SMTP Client
SmtpClient client = new SmtpClient();
// Google Port
client.Port = 587;
client.Credentials = new NetworkCredential(From.Text, password.Text);
client.UseDefaultCredentials = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Send(mail);
Label.Text = "Sent Successful";
I am getting error near Send(mail) 我在发送(邮件)附近遇到错误
You're not setting the SMTP server address? 您没有设置SMTP服务器地址吗?
Assuming your credentials are correct then you should use SmtpClient client = new SmtpClient("smtp.gmail.com")
and client.Port = 465
. 假设您的凭据正确无误,则应使用
SmtpClient client = new SmtpClient("smtp.gmail.com")
和client.Port = 465
。 587 is for TLS 587适用于TLS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.