.NET SmtpClient sending EHLO vs HELO
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 , Obj开发者_开发知识库ect[] , 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@host.com">
<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.
精彩评论