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 错误期间,客户端未通过身份验证发送匿名邮件


- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01