<mail>

Sends an SMTP message.

Text and text files to include in the message body may be specified as well as binary attachments.

Parameters

Attribute Type Description Required
from string
Email address of sender.
True
bcclist string
Semicolon-separated list of BCC: recipient email addresses.
False
cclist string
Semicolon-separated list of CC: recipient email addresses.
False
ssl bool
Indicates whether or not ssl should be used to connect to the smtp host.
False
format
Format of the message. The default is NAnt.Core.Tasks.MailTask.MailFormat.Text.
Obsolete. The format attribute is deprecated. Please use isbodyhtml instead
False
isbodyhtml bool
Indicates whether or not the body of the email is in html format. The default value is false.
False
mailhost string
Host name of mail server. The default is localhost.
False
message string
Text to send in body of email message.
False
password string
The password to use when connecting to the smtp host.
False
mailport int
The port number used to connect to the mail server. The default is 25.
False
replyto string
Reply to email address.
False
subject string
Text to send in subject line of email message.
False
tolist string
Semicolon-separated list of recipient email addresses.
False
user string
The username to use when connecting to the smtp host.
False
failonerror bool
Determines if task failure stops the build, or is just reported. The default is true.
False
if bool
If true then the task will be executed; otherwise, skipped. The default is true.
False
unless bool
Opposite of NAnt.Core.Task.IfDefined. If false then the task will be executed; otherwise, skipped. The default is false.
False
verbose bool
Determines whether the task should report detailed build log messages. The default is false.
False

Nested elements

<attachments>

Attachments that are transmitted with the message.

</attachments>

<files>

Files that are transmitted as part of the body of the email message.

</files>

Examples

Sends an email from nant@sourceforge.net to three recipients with a subject about the attachments. The body of the message will be the combined contents of all .txt files in the base directory. All zip files in the base directory will be included as attachments. The message will be sent using the smtpserver.anywhere.com SMTP server.

    <mail 
    from="nant@sourceforge.net" 
    tolist="recipient1@sourceforge.net" 
    cclist="recipient2@sourceforge.net" 
    bcclist="recipient3@sourceforge.net" 
    subject="Msg 7: With attachments" 
    mailhost="smtpserver.anywhere.com">
    <files>
        <include name="*.txt" />
    </files>   
    <attachments>
        <include name="*.zip" />
    </attachments>
</mail>

Sends an email from a gmail account to multiple recipients. This example illustrates how to add a recipient's name to an email address.

<mail
from="+xxxx+@gmail.com"
tolist="(Rep A) recipient1@sourceforge.net;(Rep B) recipient2@sourceforge.net"
subject="Sample Email"
mailhost="smtp.gmail.com"
mailport="465"
ssl="true"
user="+xxxx+@gmail.com"
password="p@ssw0rd!"
message="Email from NAnt" />

Email addresses in any of the lists (to, cc, bcc, from) can be in one of the five listed formats below.

  • Full Name <address@abcxyz.com>
  • <address@abcxyz.com> Full Name
  • (Full Name) address@abcxyz.com
  • address@abcxyz.com (Full Name)
  • address@abcxyz.com

Remember to use &gt; and &lt; XML entities for the angle brackets.

Requirements

Assembly
NAnt.Core.dll
Namespace
NAnt.Core.Tasks