public class SendMailCommand
extends java.lang.Object
Constructor and Description |
---|
SendMailCommand()
Standard-Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addAttachment(java.io.File attachment)
Adds an attachment to current message - to be called by
SmtpSampler-object
|
void |
addHeader(java.lang.String headerName,
java.lang.String headerValue)
Adds a header-part to current HashMap of headers - to be called by
SmtpSampler-object
|
void |
clearAttachments()
Clear all attachments for current message
|
void |
clearHeaders()
Deletes all current headers in HashMap
|
void |
execute()
Processes prepareMessage() and execute()
|
void |
execute(javax.mail.Message message)
Sends message to mailserver, waiting for delivery if using synchronous
mode.
|
java.util.List<java.io.File> |
getAttachments()
Returns all attachment for current message - standard getter
|
java.lang.String |
getConnectionTimeout()
Returns connection timeout for the SMTP-connection - returns the
default connection timeout if no value has been supplied.
|
CollectionProperty |
getHeaders()
Returns headers for current message - standard getter
|
java.lang.String |
getPassword()
Returns password to authenticate at the mailserver - standard getter
|
java.util.List<javax.mail.internet.InternetAddress> |
getReceiverBCC()
Returns receivers of current message as
InternetAddress ("bcc") - standard
getter |
java.util.List<javax.mail.internet.InternetAddress> |
getReceiverCC()
Returns receivers of current message as
InternetAddress ("cc") - standard
getter |
java.lang.String |
getSender()
Returns sender-address for current message - standard getter
|
java.lang.String |
getSmtpPort()
Returns port to be used for SMTP-connection (standard 25 or 465) -
standard getter
|
java.lang.String |
getSmtpServer()
Returns FQDN or IP of SMTP-server to be used to send message - standard
getter
|
java.lang.String |
getSubject()
Returns subject for current message - standard getter
|
java.lang.String |
getTimeout()
Returns timeout for the SMTP-connection - returns the
default timeout if no value has been supplied.
|
java.lang.String |
getTlsProtocolsToUse() |
java.lang.String |
getUsername()
Returns username to authenticate at the mailserver - standard getter
|
boolean |
getUseSSL()
Returns if SSL is used to send message - standard getter
|
boolean |
getUseStartTLS()
Returns if StartTLS is used to transmit message - standard getter
|
boolean |
isEnforceStartTLS()
Returns if StartTLS is enforced to secure the connection, i.e. no
fallback is used (plain SMTP) - standard getter
|
boolean |
isSynchronousMode()
Returns if synchronous-mode is used for current message (i.e. time for
delivery, ... is measured) - standard getter
|
boolean |
isTrustAllCerts()
Returns if sampler should trust all certificates - standard getter
|
boolean |
isUseAuthentication()
Returns if authentication is used to access the mailserver - standard
getter
|
javax.mail.Message |
prepareMessage()
Prepares message prior to be sent via execute()-method, i.e. sets
properties such as protocol, authentication, etc.
|
void |
setAttachments(java.util.List<java.io.File> attachments)
Adds attachments to current message
|
void |
setConnectionTimeOut(java.lang.String connectionTimeOut) |
void |
setEmlMessage(java.lang.String emlMessage)
Sets eml-message to be sent
|
void |
setEnableDebug(boolean selected) |
void |
setEnforceStartTLS(boolean enforceStartTLS)
Instructs object to enforce StartTLS and not to fallback to plain
SMTP-connection - to be called by SmtpSampler-object
|
void |
setHeaderFields(CollectionProperty headerFields)
Sets headers for current message
|
void |
setMailBody(java.lang.String body)
Set the mail body.
|
void |
setPassword(java.lang.String password)
Sets password to authenticate at the mailserver - to be called by
SmtpSampler-object
|
void |
setPlainBody(boolean plainBody)
Set whether to send a plain body (i.e. not multipart/mixed)
|
void |
setReceiverBCC(java.util.List<javax.mail.internet.InternetAddress> receiverBCC)
Sets receivers of current message ("bcc") - to be called by
SmtpSampler-object
|
void |
setReceiverCC(java.util.List<javax.mail.internet.InternetAddress> receiverCC)
Sets receivers of current message ("cc") - to be called by
SmtpSampler-object
|
void |
setReceiverTo(java.util.List<javax.mail.internet.InternetAddress> receiverTo)
Sets receivers of current message ("to") - to be called by
SmtpSampler-object
|
void |
setReplyTo(java.util.List<javax.mail.internet.InternetAddress> replyTo) |
void |
setSender(java.lang.String sender)
Sets the sender-address for the current message - to be called by
SmtpSampler-object
|
void |
setSmtpPort(java.lang.String smtpPort)
Sets port to be used for SMTP-connection (standard 25 or 465) - to be
called by SmtpSampler-object
|
void |
setSmtpServer(java.lang.String smtpServer)
Sets FQDN or IP of SMTP-server to be used to send message - to be called
by SmtpSampler-object
|
void |
setSubject(java.lang.String subject)
Sets subject for current message - called by SmtpSampler-object
|
void |
setSynchronousMode(boolean synchronousMode)
Sets the use of synchronous-mode (i.e. time for delivery, ... is
measured) - to be called by SmtpSampler-object
|
void |
setTimeOut(java.lang.String timeOut) |
void |
setTlsProtocolsToUse(java.lang.String tlsProtocols)
Sets the list of protocols to be used on TLS handshake
|
void |
setTrustAllCerts(boolean trustAllCerts)
Determines if SMTP-sampler should trust all certificates, no matter what
CA - to be called by SmtpSampler-object
|
void |
setTrustStoreToUse(java.lang.String trustStoreToUse)
Sets the path to the local truststore to be used for SSL / StartTLS - to
be called by SmtpSampler-object
|
void |
setUseAuthentication(boolean useAuthentication)
Sets if authentication should be used to access the mailserver - to be
called by SmtpSampler-object
|
void |
setUseEmlMessage(boolean sendEmlMessage) |
void |
setUseLocalTrustStore(boolean useLocalTrustStore)
Assigns the object to use a local truststore for SSL / StartTLS - to be
called by SmtpSampler-object
|
void |
setUsername(java.lang.String username)
Sets username to authenticate at the mailserver - to be called by
SmtpSampler-object
|
void |
setUseSSL(boolean useSSL)
Sets SSL to secure the delivery channel for the message - to be called by
SmtpSampler-object
|
void |
setUseStartTLS(boolean useStartTLS)
Sets StartTLS to secure the delivery channel for the message - to be
called by SmtpSampler-object
|
public javax.mail.Message prepareMessage() throws javax.mail.MessagingException, java.io.IOException
javax.mail.MessagingException
- when problems constructing or sending the mail occurjava.io.IOException
- when the mail content can not be read or truststore problems
are detectedpublic void execute(javax.mail.Message message) throws javax.mail.MessagingException, java.lang.InterruptedException
message
- Message previously prepared by prepareMessage()javax.mail.MessagingException
- when problems sending the mail arisejava.lang.InterruptedException
- when interrupted while waiting for delivery in synchronous
modepublic void execute() throws javax.mail.MessagingException, java.io.IOException, java.lang.InterruptedException
java.lang.InterruptedException
- when interrupted while waiting for delivery in synchronous
modusjava.io.IOException
- when the mail content can not be read or truststore problems
are detectedjavax.mail.MessagingException
- when problems constructing or sending the mail occurpublic java.lang.String getSmtpServer()
public void setSmtpServer(java.lang.String smtpServer)
smtpServer
- FQDN or IP of SMTP-serverpublic java.lang.String getSender()
public void setSender(java.lang.String sender)
sender
- Sender-address for current messagepublic java.lang.String getSubject()
public void setSubject(java.lang.String subject)
subject
- Subject for message of current message - may be nullpublic java.lang.String getUsername()
public void setUsername(java.lang.String username)
username
- Username for mailserverpublic java.lang.String getPassword()
public void setPassword(java.lang.String password)
password
- Password for mailserverpublic void setReceiverTo(java.util.List<javax.mail.internet.InternetAddress> receiverTo)
receiverTo
- List of receiverspublic java.util.List<javax.mail.internet.InternetAddress> getReceiverCC()
InternetAddress
("cc") - standard
getterpublic void setReceiverCC(java.util.List<javax.mail.internet.InternetAddress> receiverCC)
receiverCC
- List of receiverspublic java.util.List<javax.mail.internet.InternetAddress> getReceiverBCC()
InternetAddress
("bcc") - standard
getterpublic void setReceiverBCC(java.util.List<javax.mail.internet.InternetAddress> receiverBCC)
receiverBCC
- List of receiverspublic boolean isUseAuthentication()
public void setUseAuthentication(boolean useAuthentication)
useAuthentication
- Should authentication be used to access mailserver?public boolean getUseSSL()
public void setUseSSL(boolean useSSL)
useSSL
- Should StartTLS be used to secure SMTP-connection?public boolean getUseStartTLS()
public void setUseStartTLS(boolean useStartTLS)
useStartTLS
- Should StartTLS be used to secure SMTP-connection?public java.lang.String getSmtpPort()
public void setSmtpPort(java.lang.String smtpPort)
smtpPort
- Port to be used for SMTP-connectionpublic boolean isTrustAllCerts()
public void setTrustAllCerts(boolean trustAllCerts)
trustAllCerts
- Should all certificates be trusted?public void setEnforceStartTLS(boolean enforceStartTLS)
enforceStartTLS
- Should StartTLS be enforced?public boolean isEnforceStartTLS()
public CollectionProperty getHeaders()
public void setHeaderFields(CollectionProperty headerFields)
headerFields
- CollectionProperty of headers for current messagepublic void addHeader(java.lang.String headerName, java.lang.String headerValue)
headerName
- Key for current headerheaderValue
- Value for current headerpublic void clearHeaders()
public java.util.List<java.io.File> getAttachments()
public void setAttachments(java.util.List<java.io.File> attachments)
attachments
- List of files to be added as attachments to current messagepublic void addAttachment(java.io.File attachment)
attachment
- File-object to be added as attachment to current messagepublic void clearAttachments()
public boolean isSynchronousMode()
public void setSynchronousMode(boolean synchronousMode)
synchronousMode
- Should synchronous-mode be used?public void setTimeOut(java.lang.String timeOut)
timeOut
- the timeOut to setpublic java.lang.String getTimeout()
public void setConnectionTimeOut(java.lang.String connectionTimeOut)
connectionTimeOut
- the connectionTimeOut to setpublic java.lang.String getConnectionTimeout()
public void setUseLocalTrustStore(boolean useLocalTrustStore)
useLocalTrustStore
- Should a local truststore be used?public void setTrustStoreToUse(java.lang.String trustStoreToUse)
trustStoreToUse
- Path to local truststorepublic void setUseEmlMessage(boolean sendEmlMessage)
public void setEmlMessage(java.lang.String emlMessage)
emlMessage
- path to eml-messagepublic void setMailBody(java.lang.String body)
body
- the body of the mailpublic void setPlainBody(boolean plainBody)
plainBody
- true
if sending a plain body (i.e. not multipart/mixed)public void setEnableDebug(boolean selected)
public void setReplyTo(java.util.List<javax.mail.internet.InternetAddress> replyTo)
public void setTlsProtocolsToUse(java.lang.String tlsProtocols)
tlsProtocols
- Space separated listpublic java.lang.String getTlsProtocolsToUse()
Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.