5.7.57 SMTP - Client was not authenticated to send anonymous mail during MAIL FROM error(5.7.57 SMTP - 在 MAIL FROM 错误期间,客户端未通过身份验证发送匿名邮件)
问题描述
我必须使用我的网络应用程序发送邮件.鉴于以下代码显示 SMTP 服务器需要安全连接或客户端未通过身份验证.服务器响应是:
I have to send mails using my web application. Given the below code showing The SMTP server requires a secure connection or the client was not authenticated. The server response was:
5.7.57 SMTP;在 MAIL FROM 期间,客户端未通过身份验证发送匿名邮件.
5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM.
帮助我找到合适的解决方案.谢谢.
Help me to find a proper solution. Thank you.
代码:
protected void btnsubmit_Click(object sender, EventArgs e)
{
Ticket_MailTableAdapters.tbl_TicketTableAdapter tc;
tc = new Ticket_MailTableAdapters.tbl_TicketTableAdapter();
DataTable dt = new DataTable();
dt = tc.GetEmail(dpl_cate.SelectedValue);
foreach (DataRow row in dt.Rows)
{
string eml = (row["Emp_Email"].ToString());
var fromAddress = "emailAddress";
var toAddress = eml;
const string fromPassword = "*****";
string body = "Welcome..";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.office365.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.UseDefaultCredentials = false;
smtp.Timeout = 600000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
}
}
}
推荐答案
您似乎将 From
地址作为 emailAddress
传递,这不是正确的电子邮件地址.对于 Office365,From
需要是 Office365 系统上的真实地址.
You seem to be passing the From
address as emailAddress
, which is not a proper email address. For Office365 the From
needs to be a real address on the Office365 system.
如果您将电子邮件地址硬编码为 From
和 Office 365 密码,则可以验证这一点.
You can validate that if you hardcode your email address as the From
and your Office 365 password.
当然不要把它留在那里.
Don't leave it there though of course.
这篇关于5.7.57 SMTP - 在 MAIL FROM 错误期间,客户端未通过身份验证发送匿名邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:5.7.57 SMTP - 在 MAIL FROM 错误期间,客户端未通过身份验证发送匿名邮件
基础教程推荐
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30