smtp.send 方法抛出异常

发布于 2024-11-09 08:25:45 字数 171 浏览 0 评论 0原文

我使用 .net 版本 3.5 通过我的 Web 应用程序发送邮件,但

出现以下错误:

SMTP 服务器需要安全连接,或者客户端未经过身份验证。 服务器响应为:5.7.1 客户端未经过身份验证

可能是什么原因导致的?

I am using .net version 3.5 for sending mails though my web application

I get the following error:

The SMTP server requires a secure connection or the client was not authenticated.
The server response was: 5.7.1 Client was not authenticated

What could be causing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不疑不惑不回忆 2024-11-16 08:25:45

来源自此处 http://www.systemnetmail.com/faq/4.2.aspx

//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");

//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";

//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");

//to authenticate we set the username and password properites on the SmtpClient
smtp.Credentials = new NetworkCredential("username", "secret"); 
smtp.Send(mail);

编辑:这个错误的意思是这样写的:smtp 服务器需要身份验证信息(用户名和密码)。因此,您需要设置SmtpClient.Credentials。

Source from here http://www.systemnetmail.com/faq/4.2.aspx

//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");

//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";

//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");

//to authenticate we set the username and password properites on the SmtpClient
smtp.Credentials = new NetworkCredential("username", "secret"); 
smtp.Send(mail);

EDIT: This error means what it's written: smtp server needs authentication information (username and password). So, you need set SmtpClient.Credentials.

原来是傀儡 2024-11-16 08:25:45

尝试:

smtpclient.EnableSsl = true;

Try:

smtpclient.EnableSsl = true;
〃温暖了心ぐ 2024-11-16 08:25:45

SMTP 服务器需要一个安全的
连接或客户端未连接
已验证。 服务器响应
是:5.7.1 客户端不是
已验证

因此您需要通过添加凭据进行身份验证

smtpClient.Credentials = new NetworkCredential("username", "password"); 

The SMTP server requires a secure
connection or the client was not
authenticated. The server response
was: 5.7.1 Client was not
authenticated

so you need to authenticate by adding credentials

smtpClient.Credentials = new NetworkCredential("username", "password"); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文