Mail target
If you want to contribute, please create a user account and contact Jarek to get edit access.
Sends log messages by email using SMTP protocol.
Supported in

Configuration Syntax
<targets>
<target xsi:type="Mail"
name="String"
header="Layout"
footer="Layout"
layout="Layout"
html="Boolean"
addNewLines="Boolean"
encoding="Encoding"
subject="Layout"
to="Layout"
bcc="Layout"
cc="Layout"
from="Layout"
body="Layout"
smtpUserName="Layout"
enableSsl="Boolean"
smtpPassword="Layout"
smtpAuthentication="Enum"
smtpServer="Layout"
smtpPort="Integer" />
</targets>
Read more about using the Configuration File.<target xsi:type="Mail"
name="String"
header="Layout"
footer="Layout"
layout="Layout"
html="Boolean"
addNewLines="Boolean"
encoding="Encoding"
subject="Layout"
to="Layout"
bcc="Layout"
cc="Layout"
from="Layout"
body="Layout"
smtpUserName="Layout"
enableSsl="Boolean"
smtpPassword="Layout"
smtpAuthentication="Enum"
smtpServer="Layout"
smtpPort="Integer" />
</targets>
Parameters
- General Options
- name - Name of the target.
- Layout Options
- header - Header.Layout
- footer - Footer.Layout
- layout - Text to be rendered.Layout Required. Default: ${longdate}|${level:uppercase=true}|${logger}|${message}
- html - Indicates whether to send message as HTML instead of plain text.Boolean Default: False
- addNewLines - Indicates whether to add new lines between log entries.Boolean
- encoding - Encoding to be used for sending e-mail.Encoding Default: UTF8
- Message Options
- subject - Mail subject.Layout Required. Default: Message from NLog on ${machinename}
- to - Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).Layout Required.
- bcc - BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).Layout
- cc - CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).Layout
- from - Sender's email address (e.g. joe@domain.com).Layout Required.
- body - Mail message body (repeated for each log message send in one mail).Layout Default: ${message}Alias for the
Layout property. - SMTP Options
- smtpUserName - Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic").Layout
- enableSsl - Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server.Boolean Default: False

This parameter is not supported in:
- NLog v1.0 for .NET Framework 1.0
- NLog v1.0 for .NET Framework 1.1
- NLog v1.0 for .NET Framework 2.0
- smtpPassword - Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic").Layout
- smtpAuthentication - SMTP Authentication mode. Default: None
Possible values: - smtpServer - SMTP Server to be used for sending.Layout Required.
- smtpPort - Port number that SMTP Server is listening on.Integer Default: 25




