gpt4 book ai didi

c# - 从CSharp/.net使用gmail SMTP发送邮件

转载 作者:太空宇宙 更新时间:2023-11-03 18:06:11 25 4
gpt4 key购买 nike

using(SmtpClient client = new SmtpClient("smtp.gmail.com", 587)) 
{
// Configure the client
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(textBox1.Text, textBox3.Text);

client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage message = new MailMessage(
textBox1.Text, // From field
textBox2.Text, // Recipient field
textBox4.Text, // Subject of the email message
richTextBox1.Text // Email message body
);

client.Send(message);

MessageBox.Show("Email has been sent.");
}


Error: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

我在使用gmail时遇到此错误,但是能够使用其他SMTP服务器发送邮件。凭据正确。

最佳答案

Gmail帐户似乎存在安全问题。

我也遇到过同样的问题,然后从this post找到了解决方案。

该帖子提到您需要通过启用“访问不太安全的应用程序”来更改“帐户权限”设置。

实际上,登录到Gmail帐户后,您会收到通知。

关于c# - 从CSharp/.net使用gmail SMTP发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29251189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com