lukencode / FluentEmail

All in one email sender for .NET. Supports popular senders (SendGrid, MailGun, etc) and Razor templates.
https://lukelowrey.com/dotnet-email-guide-2021/
MIT License
2.93k stars 429 forks source link

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

Open PHuhn opened 6 years ago

PHuhn commented 6 years ago

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 commented 6 years ago

My work-around:

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