Class MailAPI
java.lang.Object
com.jedox.etl.components.scriptapi.MailAPI
Utility class to send emails via SMTP. Only SMTP user/password authentication
is supported.
Uses the SMTP settings from Scheduler as configured in Administration → Settings.
Get the utility with ExecutionAPI.getMailer()
, compose the email with
addRecipient(String)
, setSubject(String)
and
setMessage(String)
. After the email is complete, send it with
send()
.
mailer = API.getMailer(); mailer.addRecipient("max.mustermann@example.com"); mailer.setSubject("Hello"); mailer.setMessage("Hello from Jedox Integrator!"); mailer.send();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttachment
(String filename) Adds an email attachment.void
addBccRecipient
(String recipient) Adds a blind carbon copy email recipient (Bcc)).void
addCcRecipient
(String recipient) Adds a carbon copy email recipient (Cc)).void
addRecipient
(String recipient) Adds an email recipient (To).void
enableAuth
(boolean auth) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedvoid
enableTLS
(boolean tls) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedReturns the attachments added to the current email.Returns the list of blind carbon copy recipients.Returns the list of carbon copy recipients.Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedReturns the list of email recipients (To).Returns the message text (BODY) of the email.Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedReturns the email subject.Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedDeprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedDeprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedDeprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedboolean
isAuth()
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedboolean
isTls()
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedboolean
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedvoid
reset()
Reset the current email fields.void
send()
Sends an email once its composition is complete.void
setHtmlMessage
(String message) Sets the email body.void
setMessage
(String message) Sets the email body.void
setMessage
(String message, String subType) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedvoid
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedvoid
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removed.void
setSMTPServer
(String host, String port, String user, String password) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedvoid
setSubject
(String subject) Sets the email subject.void
trustAllServers
(boolean trustAllServers) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removed
-
Constructor Details
-
MailAPI
- Throws:
MailAPI.MailException
-
-
Method Details
-
setServer
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removed. UsesetSMTPServer(String, String, String, String)
instead.Sets SMTP host and user and password.- Parameters:
host
- the SMTP hostuser
- the user for authenticationpassword
- the password for authentication
-
setSMTPServer
@Deprecated(forRemoval=true) public void setSMTPServer(String host, String port, String user, String password) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedSets required configuration values for the SMTP connection.- Parameters:
host
- the SMTP hostport
- the port to useuser
- the user for authentication, ifsender
(From) is not explicitly set, this value is also used forsender
(From)password
- the password for authentication
-
setSender
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedSets the From address of the email.- Parameters:
sender
- the email address of the sender (From)
-
addRecipient
Adds an email recipient (To). This method can be called multiple times to add more than one recipient.- Parameters:
recipient
- email address of a recipient (To)
-
addCcRecipient
Adds a carbon copy email recipient (Cc)). This method can be called multiple times to add more than one carbon copy recipient.- Parameters:
recipient
- email address of a carbon copy recipient (Cc)
-
addBccRecipient
Adds a blind carbon copy email recipient (Bcc)). This method can be called multiple times to add more than one carbon copy recipient.- Parameters:
recipient
- email address of a blind carbon copy recipient (Bcc)
-
addAttachment
public void addAttachment(String filename) throws MailAPI.MailException, com.jedox.etl.core.component.InitializationException Adds an email attachment. This method can be called multiple times to add more than one email attachment.- Parameters:
filename
- the filename of the attachment (e.g. filename.txt), the path (similar to file-based connections with location typeFileSystem
) is relative to the local files folder- Throws:
MailAPI.MailException
- if the file doesn't existcom.jedox.etl.core.component.InitializationException
- if access to the file is denied
-
setSubject
Sets the email subject.- Parameters:
subject
- the subject of the email
-
setMessage
Sets the email body.- Parameters:
message
- the text of the email body
-
setMessage
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedSets the email body.- Parameters:
message
- the text of the email bodysubType
- the MIME subtype to use (e.g."html"
)
-
setHtmlMessage
Sets the email body.- Parameters:
message
- the html of the email body
-
enableTLS
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedEnables TLS for the connection to the SMTP host.- Parameters:
tls
-true
to enable TLS,false
otherwise
-
enableAuth
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedEnables authentication for the SMTP connection.- Parameters:
auth
-true
to enable authentication,false
otherwise
-
trustAllServers
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedConfigures the SMTP connection to trust the configured SMTP host. If disabled, trust depends on the certificate the server presents.- Parameters:
trustAllServers
-true
to trust the configured SMTP host,false
to trust the SMTP host depending on the certificate it presents
-
send
Sends an email once its composition is complete.- Throws:
MailAPI.MailException
- if an error occurs while sending the email via SMTP
-
reset
public void reset()Reset the current email fields. Does not reset the configuration properties of the SMTP connection. -
getSmtpHostName
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedReturns the SMTP host name.- Returns:
- the SMTP host name
-
getSmtpPort
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedReturns the SMTP port.- Returns:
- the SMTP port
-
getSmtpAuthUser
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedReturns the user for SMTP authentication.- Returns:
- the user for authentication
-
getSmtpAuthPwd
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedReturns the password for SMTP authentication.- Returns:
- the password for authentication
-
getEmailMsgTxt
Returns the message text (BODY) of the email.- Returns:
- the message text of the email
-
getEmailMsgTxtSubType
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedReturns the MIME subtype (e.g."html"
) of the email.- Returns:
- the MIME subtype of the email
-
getEmailSubjectTxt
Returns the email subject.- Returns:
- the email subject
-
getEmailFromAddress
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedReturns the email sender (From).- Returns:
- the email sender (From)
-
isTls
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedTests if TLS is enabled for the connection to the SMTP host.- Returns:
true
if TLS is enabled,false
otherwise
-
isAuth
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedTests if authentication is enabled for the SMTP connection.- Returns:
true
if authentication is enabled,false
otherwise
-
isTrustAllServers
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removedTests if the SMTP connection is configured to trust the configured SMTP host. If disabled, trust depends on the certificate the server presents- Returns:
true
if the SMTP connection is configured to trust the configured SMTP host,false
otherwise
-
getEmailList
Returns the list of email recipients (To).- Returns:
- the list of email recipients (To) as a
Set
-
getCcList
Returns the list of carbon copy recipients.- Returns:
- the list of carbon copy recipients as a
Set
-
getBccList
Returns the list of blind carbon copy recipients.- Returns:
- the list of blind carbon copy recipients as a
Set
-
getAttachmentsList
Returns the attachments added to the current email.- Returns:
- the list of attachments of the current email
-