Skip to content

log4net.Ext.Mail - #302

Draft
FreeAndNil wants to merge 11 commits into
masterfrom
Feature/302-log4net.Ext.Mail
Draft

log4net.Ext.Mail#302
FreeAndNil wants to merge 11 commits into
masterfrom
Feature/302-log4net.Ext.Mail

Conversation

@FreeAndNil

@FreeAndNil FreeAndNil commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

fixes #300

Microsoft no longer recommends System.Net.Mail.SmtpClient, and it increasingly
fails against modern mail servers. This adds a satellite assembly
log4net.Ext.Mail with a MailKit based SmtpAppender, so log4net itself takes on
no mail dependency.

  • Same options as log4net.Appender.SmtpAppender - migrating means changing only
    the type attribute.
  • Behaviour differences: smtpHost is required, enableSsl negotiates implicit
    TLS/STARTTLS automatically, Ntlm needs explicit credentials (MailKit cannot
    reuse the Windows logon session), and semicolon-separated recipient lists now
    parse correctly.
  • Site docs now recommend the new appender; all SMTP samples use it.
  • Adds Log4NetAssert.EnsureNotNullOrEmpty.

Also included, unrelated to #300: TelnetAppender registers the client before
sending the welcome banner, fixing a HasConnections race that dropped messages.

log4net.Ext.Mail.Appender.SmtpAppender exposes the same options as
log4net.Appender.SmtpAppender, but sends via MailKit instead of the obsolete
System.Net.Mail.SmtpClient. Sending goes through the new ISmtpTransport
abstraction (default: MailKitSmtpTransport) so the appender can be tested
without an SMTP server.
  (log messages could be dropped via HasConnections race)
- test: free TCP port, locked receive buffer, assert on stream
  content instead of read count, 30s timeout, log client errors
Recommend the MailKit appender from log4net.Ext.Mail over the built-in one,
which relies on the deprecated System.Net.Mail.SmtpClient, and port all
configuration samples to the new type. Adds the changelog entry for #300.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SmtpAppender uses not recomended SmptClient

1 participant