GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - NLog/NLog.MailKit: :mailbox_with_mail: Alternative Mail target for NLog using MailKit

BranchesTags
Open more actions menu

Latest commit

 

History

222 Commits
222 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src
src
 
 
test/NLog.MailKit.Tests
test/NLog.MailKit.Tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
codecov.yml
codecov.yml
 
 

Repository files navigation

NLog.MailKit

NuGet Build and test Bugs Vulnerabilities codecov

Alternative Mail target for NLog using MailKit.

The NLog MailKit Target is able to replace the original NLog Mail Target and provides the same options.

See the NLog Wiki for available options and examples.

  • Combine with FallbackGroup to fallback to alternative SMTP-server on error.
  • Combine with BufferingWrapper and AutoFlushWrapper to group multiple logevents into a single email.
  • Combine with LimitingWrapper to throttle the number of emails.
  • Combine with FilteringWrapper to avoid repeating identical emails.

If having trouble with output, then check NLog InternalLogger for clues. See also Troubleshooting NLog

This library is integration tested with the SmtpServer NuGet package

How to use

  1. Install the package:

    Install-Package NLog.MailKit or in your csproj:

    <PackageReference Include="NLog.MailKit" Version="6.*" />
  2. Add to your nlog.config:

    <extensions>
        <add assembly="NLog.MailKit"/>
    </extensions>

    Alternative register from code using fluent configuration API:

    LogManager.Setup().SetupExtensions(ext => ext.RegisterTarget<NLog.MailKit.MailTarget>());

Note that the option skipCertificateValidation="true" can prevent AuthenticationException if your remote certificate for smtpServer is invalid - not recommend!

OAuth2 Authentication

Mailkit supports OAuth2 authentication by specifying SmtpAuthentication = OAuth2 together with:

  • SmtpUserName = ${gdc:OAuthClientId}
  • SmtpPassword = ${gdc:OAuthClientSecret}

Before using OAuth2 authentication, make sure to acquire an access token from your email provider (e.g., Gmail, Outlook). This can be implemented with a Custom NLog Layout Renderer, or by storing the details in environment variable or NLog Global Diagnostics Context (GDC) and point SmtpUserName and SmtpPassword to these locations.

  • Using OAuth2 With Microsoft Outlook Exchange
  • Using OAuth2 With Google GMail

License

BSD. License of MailKit is MIT

Builds

Build, test, and NuGet publishing run on GitHub Actions. See ci.yml.

About

📬 Alternative Mail target for NLog using MailKit

Topics

csharpdotnetemailmailmailkitnet-corenetstandardnetstandard20nlognlog-targetsmtp

Resources

Readme
BSD-3-Clause license
Activity
Custom properties

Stars

17 stars

Watchers

3 watching

Forks

11 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.