https://github.com/nlog/nlog.targets.mail
NLog target for sending logevents as email messages using SMTP
https://github.com/nlog/nlog.targets.mail
csharp dotnet email-sender nlog nlog-target smtp-client
Last synced: about 1 month ago
JSON representation
NLog target for sending logevents as email messages using SMTP
- Host: GitHub
- URL: https://github.com/nlog/nlog.targets.mail
- Owner: NLog
- License: bsd-3-clause
- Created: 2025-09-01T18:09:15.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2026-04-19T10:26:10.000Z (about 2 months ago)
- Last Synced: 2026-04-19T12:25:23.215Z (about 2 months ago)
- Topics: csharp, dotnet, email-sender, nlog, nlog-target, smtp-client
- Language: C#
- Homepage:
- Size: 256 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NLog Mail Target
[](https://www.nuget.org/packages/NLog.Targets.Mail)
[](https://ci.appveyor.com/project/nlog/NLog-Targets-Mail/branch/master)
NLog Mail Target for sending email using .NET SmtpClient for each logevent.
- Can also be combined with [FallbackGroup](https://github.com/NLog/NLog/wiki/FallbackGroup-target) to fallback to alternative SMTP-server on error.
- Can also be combined with [BufferingWrapper](https://github.com/NLog/NLog/wiki/BufferingWrapper-target) to group multiple logevents into a single email.
- Can also be combined with [LimitingWrapper](https://github.com/NLog/NLog/wiki/LimitingWrapper-target) to throttle the number of emails.
- Can also be combined with [FilteringWrapper](https://github.com/NLog/NLog/wiki/FilteringWrapper-target) to avoid repeating identical emails.
If having trouble with output, then check [NLog InternalLogger](https://github.com/NLog/NLog/wiki/Internal-Logging) for clues. See also [Troubleshooting NLog](https://github.com/NLog/NLog/wiki/Logging-Troubleshooting)
See the [NLog Wiki](https://github.com/NLog/NLog/wiki/Mail-target) for available options and examples.
Note there is also an alternative [NLog.MailKit](https://www.nuget.org/packages/NLog.MailKit)-nuget-package that depends on the MailKit-library.
## Register Extension
NLog will only recognize type-alias `Mail` when loading from `NLog.config`-file, if having added extension to `NLog.config`-file:
```xml
```
Alternative register from code using [fluent configuration API](https://github.com/NLog/NLog/wiki/Fluent-Configuration-API):
```csharp
LogManager.Setup().SetupExtensions(ext => {
ext.RegisterTarget();
});
```