serilog / serilog-sinks-email

A Serilog sink that writes events to SMTP email
Apache License 2.0
70 stars 68 forks source link

Modifying MailKit on non-SSL connections to pass in SecureSocketOptions.None #105

Closed jtenos closed 1 year ago

jtenos commented 2 years ago

MailKit will throw SslHandshakeException when you connect using useSsl: false.

In order to have a completely non-secure connection over port 25, you need to use the Connect overload with options: SecureSocketOptions.None.

From the MimeKit docs:

The useSsl argument only controls whether or not the client makes an SSL-wrapped connection. In other words, even if the useSsl parameter is false, SSL/TLS may still be used if the mail server supports the STARTTLS extension.

To disable all use of SSL/TLS, use the Connect(String, Int32, SecureSocketOptions, CancellationToken) overload with a value of SecureSocketOptions.None instead.

jtenos commented 1 year ago

Closing, will re-review and try to do it more cleanly next time and demonstrate value.