Serilog.Sinks.Email 4.1.0
Serilog.Sinks.Email

Sends log events by SMTP email.
ℹ️ Version 3.x of this package changes the name and structure of many configuration parameters from their 2.x names; see below for detailed information.
Package Id: Serilog.Sinks.Email
await using var log = new LoggerConfiguration()
.WriteTo.Email(
from: "app@example.com",
to: "support@example.com",
host: "smtp.example.com")
.CreateLogger();
Supported options are:
| Parameter | Description |
|---|---|
from |
The email address emails will be sent from. |
to |
The email address emails will be sent to. Multiple addresses can be separated with commas or semicolons. |
host |
The SMTP server to use. |
port |
The port used for the SMTP connection. The default is 25. |
connectionSecurity |
Choose the security applied to the SMTP connection. This enumeration type is supplied by MailKit. The default is Auto. |
credentials |
The network credentials to use to authenticate with the mail server. |
subject |
A message template describing the email subject. The default is "Log Messages". |
body |
A message template describing the format of the email body. The default is "{Timestamp} [{Level}] {Message}{NewLine}{Exception}". |
formatProvider |
Supplies culture-specific formatting information. The default is to use the current culture. |
An overload accepting EmailSinkOptions can be used to specify advanced options such as batched and/or HTML body templates.
Sending batch email
To send batch email, supply WriteTo.Email with a batch size:
await using var log = new LoggerConfiguration()
.WriteTo.Email(
options: new()
{
From = "app@example.com",
To = "support@example.com",
Host = "smtp.example.com",
},
batchingOptions: new()
{
BatchSizeLimit = 10,
BufferingTimeLimit = TimeSpan.FromSeconds(30),
})
.CreateLogger();
Batch formatting can be customized using options.Body.
Sending HTML email
To send HTML email, specify a custom IBatchTextFormatter in options.Body and set options.IsBodyHtml to true:
await using var log = new LoggerConfiguration()
.WriteTo.Email(
options: new()
{
From = "app@example.com",
To = "support@example.com",
Host = "smtp.example.com",
Body = new MyHtmlBodyFormatter(),
IsBodyHtml = true,
},
batchingOptions: new()
{
BatchSizeLimit = 10,
BufferingTimeLimit = TimeSpan.FromSeconds(30),
})
.CreateLogger();
A simplistic HTML formatter is shown below:
class MyHtmlBodyFormatter : IBatchTextFormatter
{
public void FormatBatch(IEnumerable<LogEvent> logEvents, TextWriter output)
{
output.Write("<table>");
foreach (var logEvent in logEvents)
{
output.Write("<tr>");
Format(logEvent, output);
output.Write("</tr>");
}
output.Write("</table>");
}
public void Format(LogEvent logEvent, TextWriter output)
{
using var buffer = new StringWriter();
logEvent.RenderMessage(buffer);
output.Write(WebUtility.HtmlEncode(buffer.ToString()));
}
}
No packages depend on Serilog.Sinks.Email.
.NET Framework 4.6.2
.NET Framework 4.7.1
.NET 6.0
.NET 8.0
.NET 9.0
.NET Standard 2.0
| Version | Downloads | Last updated |
|---|---|---|
| 4.1.0 | 22 | 2025-09-10 |
| 4.1.0-dev-02303 | 0 | 2025-04-19 |
| 4.1.0-dev-02301 | 0 | 2025-04-08 |
| 4.0.1-dev-00185 | 0 | 2025-04-08 |
| 4.0.0 | 6 | 2025-03-19 |
| 4.0.0-dev-00177 | 0 | 2024-06-09 |
| 3.0.0 | 0 | 2024-02-29 |
| 3.0.0-dev-00174 | 0 | 2024-06-09 |
| 3.0.0-dev-00171 | 0 | 2024-06-09 |
| 3.0.0-dev-00166 | 0 | 2024-01-04 |
| 3.0.0-dev-00161 | 0 | 2023-12-23 |
| 2.4.1-dev-00147 | 0 | 2022-02-08 |
| 2.4.1-dev-00135 | 0 | 2021-08-09 |
| 2.4.1-dev-00128 | 0 | 2021-06-04 |
| 2.4.0 | 0 | 2020-09-21 |
| 2.4.0-dev-00116 | 0 | 2020-05-18 |
| 2.3.1-dev-00101 | 0 | 2019-05-02 |
| 2.3.1-dev-00100 | 0 | 2019-04-16 |
| 2.3.1-dev-00092 | 0 | 2018-10-30 |
| 2.3.0 | 0 | 2017-07-28 |
| 2.2.2-dev-00070 | 0 | 2017-03-11 |
| 2.2.1-dev-00067 | 0 | 2017-03-04 |
| 2.2.0 | 0 | 2017-01-22 |
| 2.2.0-dev-00057 | 0 | 2017-01-17 |
| 2.1.1-dev-00056 | 0 | 2017-01-17 |
| 2.1.0 | 0 | 2016-11-22 |
| 2.1.0-dev-00048 | 0 | 2016-11-22 |
| 2.1.0-dev-00046 | 0 | 2016-10-14 |
| 2.0.0 | 0 | 2016-07-03 |
| 1.5.37 | 0 | 2015-11-13 |
| 1.5.34 | 0 | 2015-10-13 |
| 1.5.25 | 0 | 2015-09-21 |
| 1.5.23 | 0 | 2015-09-15 |
| 1.5.20 | 0 | 2015-09-14 |
| 1.5.15 | 0 | 2015-07-30 |
| 1.5.13 | 0 | 2015-04-03 |
| 1.5.11 | 0 | 2015-04-02 |
| 1.5.10 | 0 | 2015-04-01 |
| 1.5.9 | 0 | 2015-03-26 |
| 1.5.8 | 0 | 2015-03-26 |
| 1.5.5 | 0 | 2015-03-19 |
| 1.5.3 | 0 | 2015-03-13 |
| 1.4.196 | 0 | 2015-02-22 |
| 1.4.182 | 0 | 2015-02-15 |
| 1.4.168 | 0 | 2015-02-08 |
| 1.4.155 | 0 | 2015-02-01 |
| 1.4.139 | 0 | 2015-01-23 |
| 1.4.118 | 0 | 2015-01-13 |
| 1.4.113 | 0 | 2015-01-06 |
| 1.4.102 | 0 | 2014-12-21 |
| 1.4.99 | 0 | 2014-12-18 |
| 1.4.97 | 0 | 2014-12-18 |
| 1.4.76 | 0 | 2014-12-08 |
| 1.4.39 | 0 | 2014-11-26 |
| 1.4.34 | 0 | 2014-11-24 |
| 1.4.28 | 0 | 2014-11-24 |
| 1.4.27 | 0 | 2014-11-23 |
| 1.4.23 | 0 | 2014-11-21 |
| 1.4.22 | 0 | 2014-11-21 |
| 1.4.21 | 0 | 2014-11-21 |
| 1.4.18 | 0 | 2014-11-18 |
| 1.4.15 | 0 | 2014-11-04 |
| 1.4.14 | 0 | 2014-10-23 |
| 1.4.13 | 0 | 2014-10-23 |
| 1.4.12 | 0 | 2014-10-12 |
| 1.4.11 | 0 | 2014-10-08 |
| 1.4.10 | 0 | 2014-09-26 |
| 1.4.9 | 0 | 2014-09-17 |
| 1.4.8 | 0 | 2014-09-11 |
| 1.4.7 | 0 | 2014-09-01 |
| 1.4.6 | 0 | 2014-08-31 |
| 1.4.5 | 0 | 2014-08-27 |
| 1.4.4 | 0 | 2014-08-27 |
| 1.4.3 | 0 | 2014-08-25 |
| 1.4.2 | 0 | 2014-08-23 |
| 1.4.1 | 0 | 2014-08-23 |
| 1.3.43 | 0 | 2014-08-04 |
| 1.3.42 | 0 | 2014-07-30 |
| 1.3.41 | 0 | 2014-07-28 |
| 1.3.40 | 0 | 2014-07-26 |
| 1.3.39 | 0 | 2014-07-25 |
| 1.3.37 | 0 | 2014-07-25 |
| 1.3.36 | 0 | 2014-07-20 |
| 1.3.35 | 0 | 2014-07-17 |
| 1.3.34 | 0 | 2014-07-06 |
| 1.3.33 | 0 | 2014-06-30 |
| 1.3.30 | 0 | 2014-06-19 |
| 1.3.29 | 0 | 2014-06-19 |
| 1.3.28 | 0 | 2014-06-19 |
| 1.3.27 | 0 | 2014-06-18 |
| 1.3.26 | 0 | 2014-06-18 |
| 1.3.25 | 0 | 2014-06-09 |
| 1.3.24 | 0 | 2014-05-21 |
| 1.3.23 | 0 | 2014-05-20 |
| 1.3.20 | 0 | 2014-05-18 |
| 1.3.19 | 0 | 2014-05-17 |
| 1.3.18 | 0 | 2014-05-17 |
| 1.3.17 | 0 | 2014-05-17 |
| 1.3.16 | 0 | 2014-05-17 |
| 1.3.15 | 0 | 2014-05-16 |
| 1.3.14 | 0 | 2014-05-16 |
| 1.3.13 | 0 | 2014-05-16 |
| 1.3.12 | 0 | 2014-05-14 |
| 1.3.7 | 0 | 2014-05-11 |
| 1.3.6 | 0 | 2014-05-09 |
| 1.3.5 | 0 | 2014-05-06 |
| 1.3.4 | 0 | 2014-05-04 |
| 1.3.3 | 0 | 2014-04-28 |
| 1.3.1 | 0 | 2014-04-26 |
| 1.2.53 | 0 | 2014-04-26 |
| 1.2.52 | 0 | 2014-04-24 |
| 1.2.51 | 0 | 2014-04-18 |
| 1.2.50 | 0 | 2014-04-18 |
| 1.2.49 | 0 | 2014-04-17 |
| 1.2.48 | 0 | 2014-04-14 |
| 1.2.47 | 0 | 2014-04-14 |
| 1.2.45 | 0 | 2014-04-13 |
| 1.2.44 | 0 | 2014-04-09 |
| 1.2.41 | 0 | 2014-04-07 |
| 1.2.40 | 0 | 2014-04-07 |
| 1.2.39 | 0 | 2014-03-29 |
| 1.2.37 | 0 | 2014-03-29 |
| 1.2.29 | 0 | 2014-03-16 |
| 1.2.27 | 0 | 2014-03-14 |
| 1.2.26 | 0 | 2014-03-12 |
| 1.2.25 | 0 | 2014-02-20 |
| 0.9.9 | 0 | 2013-11-23 |
| 0.9.8 | 0 | 2013-11-01 |