org.apache.tools.ant.taskdefs.email

Class EmailTask

public class EmailTask extends Task

A task to send SMTP email. This is a refactoring of the SendMail and MimeMail tasks such that both are within a single task.

Since: Ant 1.5

UNKNOWN: name="mail" category="network"

Nested Class Summary
static classEmailTask.Encoding
Enumerates the encoding constants
Field Summary
static StringAUTO
Constant to show that the best available mailer should be used.
static StringMIME
Constant to allow the Mime mailer to be requested
static StringPLAIN
Constant to allow the plaintext mailer to be requested
static StringUU
Constant to allow the UU mailer to be requested
Method Summary
voidaddBcc(EmailAddress address)
Adds "bcc" address elements
voidaddCc(EmailAddress address)
Adds "cc" address element
voidaddFileset(FileSet fs)
Adds a set of files (nested fileset attribute).
voidaddFrom(EmailAddress address)
Adds a from address element
voidaddMessage(Message message)
Add a message element
voidaddReplyTo(EmailAddress address)
Adds a replyto address element
voidaddTo(EmailAddress address)
Adds a to address element
voidexecute()
Sends an email
StringgetCharset()
Returns the character set of mail message.
booleangetIncludeFileNames()
Identifies whether file names should be included
voidsetBccList(String list)
Adds "bcc" address elements
voidsetCcList(String list)
Adds "cc" address elements
voidsetCharset(String charset)
Sets the character set of mail message.
voidsetEncoding(EmailTask.Encoding encoding)
Allows the build writer to choose the preferred encoding method
voidsetFailOnError(boolean failOnError)
Indicates whether BuildExceptions should be passed back to the core
voidsetFiles(String filenames)
Adds a list of files to be attached
voidsetFrom(String address)
Shorthand to set the from address element
voidsetIncludefilenames(boolean includeFileNames)
Sets Includefilenames attribute
voidsetMailhost(String host)
Sets the host
voidsetMailport(int port)
Sets the mail server port
voidsetMessage(String message)
Shorthand method to set the message
voidsetMessageFile(File file)
Shorthand method to set the message from a file
voidsetMessageMimeType(String type)
Shorthand method to set type of the text message, text/plain by default but text/html or text/xml is quite feasible.
voidsetPassword(String password)
sets the password for SMTP auth; this requires JavaMail
voidsetReplyTo(String address)
Shorthand to set the replyto address element
voidsetSSL(boolean SSL)
tells if the user needs to send his data over SSL
voidsetSubject(String subject)
Sets the subject line of the email
voidsetToList(String list)
Adds "to" address elements
voidsetUser(String user)
sets the user for SMTP auth; this requires JavaMail

Field Detail

AUTO

public static final String AUTO
Constant to show that the best available mailer should be used.

MIME

public static final String MIME
Constant to allow the Mime mailer to be requested

PLAIN

public static final String PLAIN
Constant to allow the plaintext mailer to be requested

UU

public static final String UU
Constant to allow the UU mailer to be requested

Method Detail

addBcc

public void addBcc(EmailAddress address)
Adds "bcc" address elements

Parameters: address The email address

addCc

public void addCc(EmailAddress address)
Adds "cc" address element

Parameters: address The email address

addFileset

public void addFileset(FileSet fs)
Adds a set of files (nested fileset attribute).

Parameters: fs The fileset

addFrom

public void addFrom(EmailAddress address)
Adds a from address element

Parameters: address The address to send from

addMessage

public void addMessage(Message message)
Add a message element

Parameters: message The message object

Throws: BuildException if a message has already been added

addReplyTo

public void addReplyTo(EmailAddress address)
Adds a replyto address element

Parameters: address The address to reply to

Since: ant 1.6

addTo

public void addTo(EmailAddress address)
Adds a to address element

Parameters: address An email address

execute

public void execute()
Sends an email

getCharset

public String getCharset()
Returns the character set of mail message.

Returns: Charset of mail message.

Since: Ant 1.6

getIncludeFileNames

public boolean getIncludeFileNames()
Identifies whether file names should be included

Returns: Identifies whether file names should be included

setBccList

public void setBccList(String list)
Adds "bcc" address elements

Parameters: list comma separated list of addresses

setCcList

public void setCcList(String list)
Adds "cc" address elements

Parameters: list Comma separated list of addresses

setCharset

public void setCharset(String charset)
Sets the character set of mail message. Will be ignored if mimeType contains ....; Charset=... substring or encoding is not a mime

Since: Ant 1.6

setEncoding

public void setEncoding(EmailTask.Encoding encoding)
Allows the build writer to choose the preferred encoding method

Parameters: encoding The encoding (one of AUTO,MIME,UU,PLAIN)

setFailOnError

public void setFailOnError(boolean failOnError)
Indicates whether BuildExceptions should be passed back to the core

Parameters: failOnError The new FailOnError value

setFiles

public void setFiles(String filenames)
Adds a list of files to be attached

Parameters: filenames Comma separated list of files

setFrom

public void setFrom(String address)
Shorthand to set the from address element

Parameters: address The address to send mail from

setIncludefilenames

public void setIncludefilenames(boolean includeFileNames)
Sets Includefilenames attribute

Parameters: includeFileNames Whether to include filenames in the text of the message

setMailhost

public void setMailhost(String host)
Sets the host

Parameters: host The host to connect to

setMailport

public void setMailport(int port)
Sets the mail server port

Parameters: port The port to use

setMessage

public void setMessage(String message)
Shorthand method to set the message

Parameters: message Message body of this email.

setMessageFile

public void setMessageFile(File file)
Shorthand method to set the message from a file

Parameters: file The file from which to take the message

setMessageMimeType

public void setMessageMimeType(String type)
Shorthand method to set type of the text message, text/plain by default but text/html or text/xml is quite feasible.

Parameters: type The new MessageMimeType value

setPassword

public void setPassword(String password)
sets the password for SMTP auth; this requires JavaMail

Parameters: password

Since: ant 1.6

setReplyTo

public void setReplyTo(String address)
Shorthand to set the replyto address element

Parameters: address The address to which replies should be directed

Since: ant 1.6

setSSL

public void setSSL(boolean SSL)
tells if the user needs to send his data over SSL

Parameters: SSL

Since: ant 1.6

setSubject

public void setSubject(String subject)
Sets the subject line of the email

Parameters: subject Subject of this email.

setToList

public void setToList(String list)
Adds "to" address elements

Parameters: list Comma separated list of addresses

setUser

public void setUser(String user)
sets the user for SMTP auth; this requires JavaMail

Parameters: user

Since: ant 1.6

Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.