FluentEmail icon indicating copy to clipboard operation
FluentEmail copied to clipboard

SMTP returning 'The remote certificate is invalid according to the validation procedure.' because of Sender.UseSsl

Open PHuhn opened this issue 8 years ago • 1 comments

I am using a SMTP mock (node fake-smtp-server) to test FluentEmail.Core with SMTP sender. I am using the config file to define the SMTP configuration. My intention is to not have any additional SMTP configuration in my code. My configuration file is as follows:

<system.net>
  <mailSettings>
    <smtp deliveryMethod="Network">
      <network host="localhost" port="25" enableSsl="false" />
    </smtp>
  </mailSettings>
</system.net>

My mock is launched as follows:

 fake-smtp-server --smtp-port 25 --http-port 10080 --max 10

The default value for Sender.UseSsl is true, so I am forced to use the following to configure SMTP:

 var _defaultClient = new SmtpClient();
 var _sender = new SmtpSender(_defaultClient);
 _sender.UseSsl = false;

Additionally, is FluentEmail.Core a replacement of FluentEmail? Explanations in the docs would be appreciated.

PHuhn avatar Feb 09 '18 17:02 PHuhn

My work-around:

var _client = new SmtpClient();
var _sender = new SmtpSender(_client)
{
    UseSsl = _client.EnableSsl
};

PHuhn avatar Feb 09 '18 19:02 PHuhn