Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 2.74 KB

README.md

File metadata and controls

32 lines (26 loc) · 2.74 KB

Serilog.Sinks.NetMail Build status

ℹ️ Based on Serilog.Sinks.Email

Sends log events by SMTP email, using System.Net.Mail.

await using var log = new LoggerConfiguration()
    .WriteTo.NetMail(
        from: "[email protected]",
        to: "[email protected]",
        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.
enableSSL Enable SSL
credentials The network credentials to use to authenticate with the mail server.
useDefaultCredentials Use the Default Credentials, useful e.g. for NTML / Kerberos
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}".
bodyIsHtml Enables HTML support for body. Note unlike Email sink, there is no need for further custom code / method. It is native of System.Net.Mail.
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.