-
Notifications
You must be signed in to change notification settings - Fork 0
Mail target
Sends log messages by email using SMTP protocol.
Supported in .NET and Mono ##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](Configuration file). ##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:
- Basic - Basic - username and password.
- None - No authentication.
- Ntlm - NTLM Authentication.
smtpServer - SMTP Server to be used for sending. Layout Required.
smtpPort - Port number that SMTP Server is listening on. Integer Default: 25
##Remarks If the application config file contains mail settings, fx.:
<system.net>
<mailSettings>
<smtp from="mail@domain.com" deliveryMethod="SpecifiedPickupDirectory">
<network host="localhost" port="25"/>
<specifiedPickupDirectory pickupDirectoryLocation="C:/Temp/Email"/>
</smtp>
</mailSettings>
</system.net>
These values will be used, if target doesn't override them.