serilog-sinks-email
serilog-sinks-email copied to clipboard
Are there plans to upgrade the MailKit dependency to 3.0+?
The current email sink is using MailKit 2.6.
The newer MailKit 3.0
version has some upgrades, including server responses when an email is sent. We had to downgrade our MailKit version to match the Serilog MailKit version and have lost some of the new features.
Are there any plans to upgrade MailKit to 3.0+?
I will second that - please update - MailKit is now v3.2.0 - this is holding back on progress. thanks
I'd like to third this. I was also able to work around the incompatibility temporarily by installing a downgraded version of MailKit (2.15.0) in my app which otherwise doesn't rely on it, but it would really be good to be able to use a current version of MailKit. It's now up to 3.4.1. Downgrading MailKit isn't a very good option for most applications on .NET 6.0+.
I second this too, we need an updated version using an updated version of Mailkit
Yes, this issue should be high priority, I see other issues that I think are related to this. When you have project referencing MailKit 3.0+, serilog email no longer functions at all because the method signature changed in 3.0. If you enable Serilog self loging:
Serilog.Debugging.SelfLog.Enable(Console.WriteLine);
You will see the error immediately:
2022-11-17T01:47:32.0825666Z Exception while emitting periodic batch from Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink: System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task MailKit.MailTransport.SendAsync(MimeKit.MimeMessage, System.Threading.CancellationToken, MailKit.ITransferProgress)'.
at Serilog.Sinks.Email.EmailSink.EmitBatchAsync(IEnumerable1 events) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Serilog.Sinks.Email.EmailSink.EmitBatchAsync(IEnumerable
1 events)
at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.OnTick()
There are stack overflow issues referencing this: https://stackoverflow.com/questions/70886057/serilog-writeto-email-failing
The serilog nuget needs to be updated....
@nblumhardt Thoughts?
Thanks for the ping! Agreed - if anyone's able to send a PR (and check that everything still works as expected with the new MailKit version) I can review/merge 👍
@nblumhardt I started to take a look at upgrading MailKit and had a few questions:
SmtpClient vs MailKit
net45/47 are targeting SmtpClient
, while netstandard1.3/2.0/2.1 are targeting MailKit
. MS recommends not to use SmtpClient
anymore; shouldn't all targets being using MailKit
?
Deprecated Frameworks
netstandard1.3/2.0/2.1 have targeted builds; are you still wanting to support netstandard
? Or can they be purged?
Thanks!
Hi @nCubed! Thanks for checking it out.
RE SmtpClient vs MailKit: I think the main issue with switching will be breakage - if it's possible to leave the older frameworks on SmtpClient without causing trouble for the newer ones then that will be best.
RE deprecated frameworks, Serilog generally tries to keep support alive for these as long as we can do it without major headaches. Microsoft's support lifecycle takes into account being able to debug people's production problems on those frameworks and patch if necessary. For Serilog, the burden of supporting them is much lower, as long as they're API compatible with whatever is currently in support.
Let me know what you think!
Only net4.5/4.7 are on the SMTP client. Everything else is already on MailKit.
Looking at Mailkit's dependencies, I think everything can be upgraded to the latest MailKit version except netstandard1.3 which would need to stay at MailKit 2.6. The only questionable target is net4.5 b/c the more current MailKit 3.x targets net4.5.2, so just keep 45 with the old SmtpClient.
I'd propose the following targets:
.net | legacy | MailKit 3.4.3 | New Target |
---|---|---|---|
netstandard 1.3 | MailKit 2.6 | ||
netstandard 2.0 | x | ||
netstandard 2.1 | x | ||
net45 | SmtpClient | ||
net47 | x | ||
net48 | x | x | |
net6.0 | x | x |
My dev machine doesn't have the older/deprecated frameworks, but as long as the current build works, then PR should build just fine.
Thoughts?
Thanks for the reply! By "breakage" I mean that SmtpClient
delivery behavior is different from MailKit's, especially around TLS certificate acceptance, so it's more a question of the impact of those changes than MailKit's platform support, if that makes sense?
Any progress on implementing MailKit 3+ support?
Thanks for the ping! Agreed - if anyone's able to send a PR (and check that everything still works as expected with the new MailKit version) I can review/merge 👍
Try my pull request #112 I tested it and work fine.
I accidentally updated the Mailkit library in our project to the latest version (again) and since then sending email has stopped working. How could this not be a high priority issue? I'm struggling with this for more than a year now. Might consider using another logging library as this is an important notification method in our workflow.
I have been following this repo as the lack of a flush on shutdown is a problem for one of my use cases, but I want to wait for this issue before I attempt to fix my own.
Can we agree to drop support for the old net45
framework? If so, then targeting netstandard2.0
will cover all the frameworks needed, past and present as well as support MailKit.
Hi all!
The TFM list for Serilog 3 (up soon!) will be:
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net471</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);netstandard2.1;netstandard2.0;net5.0;net6.0;net7.0</TargetFrameworks>
This might be the right time to make some breaking changes and drop the System.Net.Mail dependency in favor of MailKit across the board.
(Thanks for trying it out earlier on, @ficnar!)
Is anyone following along keen to work on this? I think the aim would be to simplify the project setup as much as possible, to match the TFMs above exactly, and to keep a good handle on breaking changes so that the support load is manageable once it's released.
@nblumhardt Do you have an approximate timeframe for the release you mentioned? I'm working on some planning for the next few months and would like to include the update if possible. Thanks!
Hi @chekm8 - I think all of the pieces are in place now for this to go forward (Serilog 3 is out), so the timeframe will come down to someone finding the time to work on it (I'd love to but I can't see when it'll fit in right now).
If you/someone else is following along might be keen to give it a go - the main task is ensuring we're on top of what the breaking changes are, the PR itself should be fairly straightforward.
During migration of our project from .net 7 to .net 8 I upgraded Mailkit to version 4.3. No errors but logs are not sent by email anymore. Will there be a fix in the near future so I don't have to downgrade Mailkit to version 2.15?
Done now in 3.0.0-dev. The package needs some testing/feedback/minor work to get going smoothly with System.Net.Mail.SmtpClient removed - all help appreciated.
Can't this be closed since 4.0 is out and uses mailkit 4.7.1.1 ?