org.apache.tools.ant.taskdefs.email

Class Mailer

public abstract class Mailer extends Object

Base class for the various emailing implementations.

Since: Ant 1.5

Field Summary
protected VectorbccList
protected VectorccList
protected Vectorfiles
protected EmailAddressfrom
protected Vectorheaders
protected Stringhost
protected booleanincludeFileNames
protected Messagemessage
protected Stringpassword
protected intport
protected VectorreplyToList
protected Stringsubject
protected booleanSSL
protected Tasktask
protected VectortoList
protected Stringuser
Method Summary
protected StringgetDate()
Return the current Date in a format suitable for a SMTP date header.
protected booleanisStartTLSEnabled()
abstract voidsend()
Send the email.
voidsetBccList(Vector list)
Set the bcc addresses.
voidsetCcList(Vector list)
Set the cc addresses.
voidsetEnableStartTLS(boolean b)
Set whether to allow authentication to switch to a TLS connection via STARTTLS.
voidsetFiles(Vector files)
Set the files to attach.
voidsetFrom(EmailAddress from)
Set the address to send from.
voidsetHeaders(Vector v)
Set the generic headers to add to the email.
voidsetHost(String host)
Set the mail server.
voidsetIgnoreInvalidRecipients(boolean b)
Whether invalid recipients should be ignored (but a warning will be logged) instead of making the task fail.
voidsetIncludeFileNames(boolean b)
Indicate whether filenames should be listed in the body.
voidsetMessage(Message m)
Set the message.
voidsetPassword(String password)
Set the password for smtp auth.
voidsetPort(int port)
Set the smtp port.
voidsetReplyToList(Vector list)
Set the replyto addresses.
voidsetSSL(boolean ssl)
Set whether to send the mail through SSL.
voidsetSubject(String subject)
Set the subject.
voidsetTask(Task task)
Set the owning task.
voidsetToList(Vector list)
Set the to addresses.
voidsetUser(String user)
Set the user for smtp auth.
protected booleanshouldIgnoreInvalidRecipients()
Whether invalid recipients should be ignored.

Field Detail

bccList

protected Vector bccList

ccList

protected Vector ccList

files

protected Vector files

from

protected EmailAddress from

headers

protected Vector headers

host

protected String host

includeFileNames

protected boolean includeFileNames

message

protected Message message

password

protected String password

port

protected int port

replyToList

protected Vector replyToList

subject

protected String subject

SSL

protected boolean SSL

task

protected Task task

toList

protected Vector toList

user

protected String user

Method Detail

getDate

protected final String getDate()
Return the current Date in a format suitable for a SMTP date header.

Returns: the current date in SMTP suitable format.

Since: Ant 1.5

isStartTLSEnabled

protected boolean isStartTLSEnabled()

send

public abstract void send()
Send the email.

Throws: BuildException if the email can't be sent.

setBccList

public void setBccList(Vector list)
Set the bcc addresses.

Parameters: list a vector of the bcc addresses.

setCcList

public void setCcList(Vector list)
Set the cc addresses.

Parameters: list a vector of cc addresses.

setEnableStartTLS

public void setEnableStartTLS(boolean b)
Set whether to allow authentication to switch to a TLS connection via STARTTLS.

Parameters: b boolean; if true STARTTLS will be supported.

Since: Ant 1.8.0

setFiles

public void setFiles(Vector files)
Set the files to attach.

Parameters: files list of files to attach to the email.

setFrom

public void setFrom(EmailAddress from)
Set the address to send from.

Parameters: from the sender.

setHeaders

public void setHeaders(Vector v)
Set the generic headers to add to the email.

Parameters: v a Vector presumed to contain Header objects.

Since: Ant 1.7

setHost

public void setHost(String host)
Set the mail server.

Parameters: host the mail server name.

setIgnoreInvalidRecipients

public void setIgnoreInvalidRecipients(boolean b)
Whether invalid recipients should be ignored (but a warning will be logged) instead of making the task fail.

Even with this property set to true the task will still fail if the mail couldn't be sent to any recipient at all.

Since: Ant 1.8.0

setIncludeFileNames

public void setIncludeFileNames(boolean b)
Indicate whether filenames should be listed in the body.

Parameters: b if true list attached file names in the body content.

setMessage

public void setMessage(Message m)
Set the message.

Parameters: m the message content.

setPassword

public void setPassword(String password)
Set the password for smtp auth.

Parameters: password the authentication password.

Since: Ant 1.6

setPort

public void setPort(int port)
Set the smtp port.

Parameters: port the SMTP port.

setReplyToList

public void setReplyToList(Vector list)
Set the replyto addresses.

Parameters: list a vector of reployTo addresses.

Since: Ant 1.6

setSSL

public void setSSL(boolean ssl)
Set whether to send the mail through SSL.

Parameters: ssl if true use SSL transport.

Since: Ant 1.6

setSubject

public void setSubject(String subject)
Set the subject.

Parameters: subject the subject line.

setTask

public void setTask(Task task)
Set the owning task.

Parameters: task the owning task instance.

setToList

public void setToList(Vector list)
Set the to addresses.

Parameters: list a vector of recipient addresses.

setUser

public void setUser(String user)
Set the user for smtp auth.

Parameters: user the username.

Since: Ant 1.6

shouldIgnoreInvalidRecipients

protected boolean shouldIgnoreInvalidRecipients()
Whether invalid recipients should be ignored.

Since: Ant 1.8.0