.NET SmtpClient 发送 EHLO 与 HELO

发布于 2024-12-06 20:40:50 字数 2367 浏览 1 评论 0原文

遇到一个特殊的问题。我有一个 SMTP 服务器,需要对其进行身份验证才能发送邮件。我们有一个 C# 服务旨在自动执行此操作,但是服务器主机已将 SMTP 服务器配置为在客户端使用 HELO 与 EHLO 启动时不允许中继。当客户端使用EHLO时,允许中继。

是否有办法维持 SmtpClient 的使用并发送 EHLO 与 HELO?

SMTP 主机提供商对 HELO/EHLO 中继问题的电子邮件回复:

“默认情况下,我们的服务器设置为对 ehlo 命令进行身份验证,并且 不是直升机。它将应答来自主机的 helo 并在本地发送邮件,但是 不中继。”

开发者发送的应用程序错误:

2011-09-14 14:32:17,764 错误 ISearchService - 未处理的异常 调用时被抛出 [AptitudeSolutions.OnCore.Services.ServiceAdapter.Search.SearchServiceAdapter]。 System.Net.Mail.SmtpException: SMTP 服务器需要安全的 连接或客户端未经过身份验证。服务器响应 是:不允许中继(在您的电子邮件上启用 smtp 身份验证 客户)在 System.Net.Mail.RecipientCommand.CheckResponse(SmtpStatusCode) 状态代码,字符串响应)位于 System.Net.Mail.SmtpTransport.SendMail(邮件地址发件人, MailAddressCollection收件人,字符串deliveryNotify, SmtpFailedRecipientException&例外)在 System.Net.Mail.SmtpClient.Send(MailMessage 消息)位于 AptitudeSolutions.OnCore.BusinessProcesses.Scenario.PublicRecordsNotification.AppServices.PublicRecordsNotificationEmailService.SendEmail(字符串 电子邮件、字符串主题、字符串正文)位于 AptitudeSolutions.OnCore.BusinessProcesses.Scenario.PublicRecordsNotification.AppServices.PublicRecordsNotificationEmailService.SendNewAccountActivationEmailTo(字符串 电子邮件)在 AptitudeSolutions.OnCore.BusinessProcesses.Scenario.PublicRecordsNotification.ServiceLayer.PublicRecordsNotificationServiceLayer.RequestNewAccount(NewAccountRequest 请求)在 AptitudeSolutions.OnCore.Services.ServiceAdapter.Search.SearchServiceAdapter.RequestNewNotificationAccount(NewAccountRequest 请求)在 SyncInvokeRequestNewNotificationAccount(Object , 对象[]、对象[])位于 System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(对象 实例,Object[] 输入,Object[]&输出)在 AptitudeSolutions.Framework.DataAccessBase.Utility.Wcf.ServiceAttributes.ExceptionLoggingOperationInvoker.Invoke(对象 实例,Object[] 输入,Object[]&输出)

配置文件的相关部分:

  <system.net>
       <mailSettings>
         <smtp from="[email protected]">
              <network host="mail.smtphost.com" port="25" userName="username" password="password" defaultCredentials="false" />
         </smtp>
       </mailSettings>
  </system.net>

出于安全目的,一些信息已被编辑。

Running into a peculiar issue. I have an SMTP server that I need to authenticate to in order to send mail. We have a C# service that is designed to automatically do this, however the server host has configured the SMTP server to not allow relaying when a client initiates with HELO vs. EHLO. When a client uses EHLO, relay is allowed.

Is there anyway to maintain SmtpClient use and send EHLO vs HELO?

Email response to HELO/EHLO relaying question from SMTP host provider:

"By default our server is setup to authenticate to ehlo commands and
not helo. It will answer helo from hosts and delivery mail locally but
not relay."

Error from the application sent by the developer:

2011-09-14 14:32:17,764 ERROR ISearchService - An unhandled exception
was thrown while invoking
[AptitudeSolutions.OnCore.Services.ServiceAdapter.Search.SearchServiceAdapter].
System.Net.Mail.SmtpException: The SMTP server requires a secure
connection or the client was not authenticated. The server response
was: Relaying not allowed (enable smtp authentication on your email
client) at
System.Net.Mail.RecipientCommand.CheckResponse(SmtpStatusCode
statusCode, String response) at
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify,
SmtpFailedRecipientException& exception) at
System.Net.Mail.SmtpClient.Send(MailMessage message) at
AptitudeSolutions.OnCore.BusinessProcesses.Scenario.PublicRecordsNotification.AppServices.PublicRecordsNotificationEmailService.SendEmail(String
email, String subject, String body) at
AptitudeSolutions.OnCore.BusinessProcesses.Scenario.PublicRecordsNotification.AppServices.PublicRecordsNotificationEmailService.SendNewAccountActivationEmailTo(String
email) at
AptitudeSolutions.OnCore.BusinessProcesses.Scenario.PublicRecordsNotification.ServiceLayer.PublicRecordsNotificationServiceLayer.RequestNewAccount(NewAccountRequest
request) at
AptitudeSolutions.OnCore.Services.ServiceAdapter.Search.SearchServiceAdapter.RequestNewNotificationAccount(NewAccountRequest
request) at SyncInvokeRequestNewNotificationAccount(Object ,
Object[] , Object[] ) at
System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object
instance, Object[] inputs, Object[]& outputs) at
AptitudeSolutions.Framework.DataAccessBase.Utility.Wcf.ServiceAttributes.ExceptionLoggingOperationInvoker.Invoke(Object
instance, Object[] inputs, Object[]& outputs)

Relevant part of config file:

  <system.net>
       <mailSettings>
         <smtp from="[email protected]">
              <network host="mail.smtphost.com" port="25" userName="username" password="password" defaultCredentials="false" />
         </smtp>
       </mailSettings>
  </system.net>

Some information has been edited for security purposes.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文