serilog / serilog-sinks-email

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

Why does the Email sink not use MailKit on Framework? #96

Closed gaazkam closed 11 months ago

gaazkam commented 3 years ago

The way I'm getting things is that the Email sink uses the deprecated System.Net.Mail.SmtpClient class if run on Framework and MailKit if run on Core or Standard. This behavior doesn't seem documented and I had to read the source code to find this out.

However, SmtpClient is disrecommended by Microsoft:

Important

We don't recommend that you use the SmtpClient class for new development because SmtpClient doesn't support many modern protocols. Use MailKit or other libraries instead. For more information, see SmtpClient shouldn't be used on GitHub.

In particular, SmtpClient does not support authenticating against SMTP servers on port 465. For this reason I was unable to make Serilog.Sinks.Email send emails. MailKit doesn't seem to have this limitation.

Unfortunately, thanks to third party library compatilbility requirements, I'm still stuck on Framework and this is expected to last for about two years.

Considering that MailKit does target Framework I think it would make sense to use MailKit even on Framework projects. Failing that I think it would make sense to add a configuration option to opt in to the use of MailKit even on Framework. In any case I think that the choice of mailing backends depending on .Net version should be explicitly documented.

xantari commented 2 years ago

@gaazkam It does use mailkit, so i'm not sure what you are referencing here. See here: https://github.com/serilog/serilog-sinks-email/blob/dev/src/Serilog.Sinks.Email/Sinks/Email/MailKitEmailTransport.cs

SylwesterZarebski commented 1 year ago

It does not use Mailkit on Framework: https://github.com/serilog/serilog-sinks-email/blob/644fe13c006ed470aaa7ce4774f224cca73fa7b7/src/Serilog.Sinks.Email/Sinks/Email/EmailConnectionInfo.cs#L110

The SystemMailEmailTransport should be removed.

nblumhardt commented 11 months ago

3.0.0-dev-* packages now use MailKit and support all options on .NET Framework.