Class Mailer
java.lang.Object
org.apache.tools.ant.taskdefs.email.Mailer
- Direct Known Subclasses:
JakartaMimeMailer
,MimeMailer
Base class for the various emailing implementations.
- Since:
- Ant 1.5
-
Field Summary
Modifier and TypeFieldDescriptionprotected Vector
<EmailAddress> protected Vector
<EmailAddress> protected EmailAddress
protected String
protected boolean
protected Message
protected String
protected int
protected Vector
<EmailAddress> protected boolean
protected String
protected Task
protected Vector
<EmailAddress> protected String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final String
getDate()
Return the current Date in a format suitable for a SMTP date header.protected boolean
Whether the port has been explicitly specified by the user.protected boolean
abstract void
send()
Send the email.void
setBccList
(Vector<EmailAddress> list) Set the bcc addresses.void
setCcList
(Vector<EmailAddress> list) Set the cc addresses.void
setEnableStartTLS
(boolean b) Set whether to allow authentication to switch to a TLS connection via STARTTLS.void
Set the files to attach.void
setFrom
(EmailAddress from) Set the address to send from.void
setHeaders
(Vector<Header> v) Set the generic headers to add to the email.void
Set the mail server.void
setIgnoreInvalidRecipients
(boolean b) Whether invalid recipients should be ignored (but a warning will be logged) instead of making the task fail.void
setIncludeFileNames
(boolean b) Indicate whether filenames should be listed in the body.void
Set the message.void
setPassword
(String password) Set the password for smtp auth.void
setPort
(int port) Set the smtp port.void
setPortExplicitlySpecified
(boolean explicit) Whether the port has been explicitly specified by the user.void
setReplyToList
(Vector<EmailAddress> list) Set the replyTo addresses.void
setSSL
(boolean ssl) Set whether to send the mail through SSL.void
setSubject
(String subject) Set the subject.void
Set the owning task.void
setToList
(Vector<EmailAddress> list) Set the to addresses.void
Set the user for smtp auth.protected boolean
Whether invalid recipients should be ignored.
-
Field Details
-
host
-
port
protected int port -
user
-
password
-
SSL
protected boolean SSL -
message
-
from
-
replyToList
-
toList
-
ccList
-
bccList
-
files
-
subject
-
task
-
includeFileNames
protected boolean includeFileNames -
headers
-
-
Constructor Details
-
Mailer
public Mailer()
-
-
Method Details
-
setHost
-
setPort
public void setPort(int port) Set the smtp port.- Parameters:
port
- the SMTP port.
-
setPortExplicitlySpecified
public void setPortExplicitlySpecified(boolean explicit) Whether the port has been explicitly specified by the user.- Parameters:
explicit
- boolean- Since:
- Ant 1.8.2
-
isPortExplicitlySpecified
protected boolean isPortExplicitlySpecified()Whether the port has been explicitly specified by the user.- Returns:
- boolean
- Since:
- Ant 1.8.2
-
setUser
Set the user for smtp auth.- Parameters:
user
- the username.- Since:
- Ant 1.6
-
setPassword
Set the password for smtp auth.- Parameters:
password
- the authentication password.- 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
-
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
-
isStartTLSEnabled
protected boolean isStartTLSEnabled() -
setMessage
-
setFrom
-
setReplyToList
Set the replyTo addresses.- Parameters:
list
- a vector of replyTo addresses.- Since:
- Ant 1.6
-
setToList
Set the to addresses.- Parameters:
list
- a vector of recipient addresses.
-
setCcList
Set the cc addresses.- Parameters:
list
- a vector of cc addresses.
-
setBccList
Set the bcc addresses.- Parameters:
list
- a vector of the bcc addresses.
-
setFiles
-
setSubject
-
setTask
-
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.
-
setHeaders
-
send
Send the email.- Throws:
BuildException
- if the email can't be sent.
-
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.
- Parameters:
b
- boolean- Since:
- Ant 1.8.0
-
shouldIgnoreInvalidRecipients
protected boolean shouldIgnoreInvalidRecipients()Whether invalid recipients should be ignored.- Returns:
- boolean
- Since:
- Ant 1.8.0
-
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
-