4

We've been running a new system in test for a while now and creating emails to a folder so they don't accidentally go out to clients. Now we've turned on live emailing we are getting issues with sending.

I'm using ActionMailer.NET and the code to create and send the email is below. I won't include the View:

EmailResult x = new EmailController().EmailWorkOrderForApprovalToClient(model);
            System.Net.Mail.Attachment file = new System.Net.Mail.Attachment(FilePath);
            x.Mail.Attachments.Add(file);
            x.Deliver();

Which gives the error

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM

The web.config looks like this:

  <system.net>
<mailSettings>
  <smtp deliveryMethod="Network" from="ClientServices@topupconsultants.com">
    <specifiedPickupDirectory pickupDirectoryLocation="" />
    <network defaultCredentials="false" host="smtp.office365.com" password="secret" port="587" userName="ClientServices@myco.com" />
  </smtp>
</mailSettings>

My assumption is that enableSsl="true" needs to be added to the network line, but when I do that and try to go to the SMTP Email section of the site in IIS, I get the error:

Unrecognized attribute 'enableSsl'

I'm not that hot on IIS, but I've checked that the Application Pool and its .NET CLR version is 4.0.30319. I've also checked that .NET v4.5 is installed on the server.

This is baffling me, and I'm hoping I don't have to totally change my code to a method that allows me to specify SSL at that point.

Red
  • 3,030
  • 3
  • 22
  • 39

2 Answers2

4

Answering my own question here, and basically the answer is: "Don't believe the error message". In all the configurations I tried, I believed the error message when it told me that is was unacceptable. However, I tried it anyway, and it uses the enableSsl attribute when it sends, and this allows the connection to Office 365 to succeed.

Slightly irritating IIS bug that I'll forget about in a week, but right now is very annoying.

Red
  • 3,030
  • 3
  • 22
  • 39
0

This is issue on IIS no need to worry about this error message SmtpClient object enableSsl value get mapped this silly issue is wasted my much time :D

LittleDragon
  • 2,317
  • 2
  • 18
  • 23