System.Net.Mail.SmtpException:SMTP服务器要求安全连接或客户端未通过身份验证 [英] System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated
问题描述
我试图发送电子邮件从一个C#应用程序。结果$ B $我的网站的地址B这几个月工作的罚款,直到最近。 (也许我的供应商改变一些事情或者别人更改的设置)
I'm trying to send email with my website's address from a C# application.
This worked fine for several months until recently. (maybe my provider changes some things or someone else changed settings)
下面的代码:
private void sendEmail(Email invite) {
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(smtpServerName);
mail.From = new MailAddress(emailUsername);
mail.To.Add(invite.RecipientEmail);
mail.Subject = invite.MessageSubject;
mail.Body = invite.MessageBody;
SmtpServer.UseDefaultCredentials = false;
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential(emailUsername, emailPassword);
// SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
}
下面的错误:
SMTP服务器要求安全连接或客户端未通过身份验证。服务器响应为:当需要SMTP认证
The SMTP server requires a secure connection or the client was not authenticated. The server response was: SMTP authentication is required.
看着其他问题我想他们建议的东西,使 SmtpServer.EnableSsl = TRUE
。这并没有在所有的工作。它给了以下内容:
Looking at other questions I tried what they suggested, to make SmtpServer.EnableSsl = true
. This didn't work at all. It gave the following:
System.Net.Mail.SmtpException:服务器不支持安全连接
System.Net.Mail.SmtpException: Server does not support secure connections.
我猜我应该禁用SSL,并请有它以前的方式。
I'm guessing I should disable SSL and have it the way it was before.
任何建议如何再次进行电子邮件发送工作?
Any suggestions how to make email sending work again?
修改结果
我已经没有 SMTPSERVER尝试。 UseDefaultCredentials = FALSE;
结果
我已经与它试图设置为true: SmtpServer.UseDefaultCredentials = TRUE;
结果
我已经尝试评论具有以下沿着这条线// SmtpServer.Credentials =新System.Net.NetworkCredential(emailUsername,emailPassword);
推荐答案
这是错误信息通常是由如下原因:
That error message is typically caused by one of the following:
- 不正确的连接设置,例如用于抵押或无安全连接
- 不正确的凭据中指定的错误的端口。我想验证用户名和密码组合,以确保证书是正确的。
这篇关于System.Net.Mail.SmtpException:SMTP服务器要求安全连接或客户端未通过身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!