5.7.57 SMTP - 在 MAIL FROM 错误期间,客户端未通过身份验证发送匿名邮件

5.7.57 SMTP - Client was not authenticated to send anonymous mail during MAIL FROM error(5.7.57 SMTP - 在 MAIL FROM 错误期间,客户端未通过身份验证发送匿名邮件)
本文介绍了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 错误期间,客户端未通过身份验证发送匿名邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)