Class MailAPI
java.lang.Object
com.jedox.etl.components.scriptapi.MailAPI
Utility class to send emails via SMTP.
Uses SMTP settings from Jedox Cloud Console.
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()
.
Note: as of Jedox 24.2, SMTP settings are configured in Jedox Cloud Console. Configuring SMTP settings in scripts is no longer possible. All affected methods likemailer = API.getMailer() mailer.addRecipient("max.mustermann@example.com") mailer.setSubject("Hello") mailer.setMessage("Hello from Jedox Integrator!") mailer.send()
setServer()
are now deprecated.
Calling any of these methods has no effect or returns null
or false
,
and a warning will be logged, notifying about the deprecation.-
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.As of Jedox 24.2, calling this method has no effect.void
enableTLS
(boolean tls) Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method has no effect.Returns 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.As of Jedox 24.2, calling this method returnsnull
.Returns 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.As of Jedox 24.2, calling this method returnsnull
.Returns the email subject.Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method returnsnull
.Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method returnsnull
.Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method returnsnull
.Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method returnsnull
.boolean
isAuth()
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method returnsfalse
.boolean
isTls()
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method returnsfalse
.boolean
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method returnsfalse
.void
reset()
Reset the current email fields.void
send()
Sends an email once its composition is complete.void
setHtmlMessage
(String message) Sets the email body (MIME typetext/html
).void
setMessage
(String message) Sets the email body (MIME typetext/plain
).void
setMessage
(String message, String subType) Deprecated, for removal: This API element is subject to removal in a future version.UsesetMessage(String)
fortext/plain
orsetHtmlMessage(String)
for messages in HTML (text/html
instead.void
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method has no effect.void
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method has no effect.void
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method has no effect.void
setSMTPServer
(String host, String port, String user, String password) Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method has no effect.void
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.As of Jedox 24.2, calling this method has no effect.
-
Constructor Details
-
MailAPI
public MailAPI() throws com.jedox.etl.components.scriptapi.MailAPI.MailException- Throws:
com.jedox.etl.components.scriptapi.MailAPI.MailException
-
-
Method Details
-
setServer
@Deprecated(since="24.2", forRemoval=true) public void setServer(String host, String user, String password) Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.Sets SMTP host and user and password.- Parameters:
host
- the SMTP hostuser
- the user for authenticationpassword
- the password for authentication
-
setServer
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.Sets server. -
setSMTPServer
@Deprecated(since="24.2", 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.As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.Sets 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.As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.Sets 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 blind carbon copy recipient.- Parameters:
recipient
- email address of a blind carbon copy recipient (Bcc)
-
addAttachment
public void addAttachment(String filename) throws com.jedox.etl.components.scriptapi.MailAPI.MailException 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:
com.jedox.etl.components.scriptapi.MailAPI.MailException
- if the file doesn't exist or if access to the file is denied
-
setSubject
Sets the email subject.- Parameters:
subject
- the subject of the email
-
setMessage
Sets the email body (MIME typetext/plain
).- Parameters:
message
- the text of the email body
-
setMessage
Deprecated, for removal: This API element is subject to removal in a future version.UsesetMessage(String)
fortext/plain
orsetHtmlMessage(String)
for messages in HTML (text/html
instead. Any other value forsubType
is ignored and MIME typetext/plain
is used (setMessage(String)
is called).Sets the email body.- Parameters:
message
- the text of the email bodysubType
- the MIME subtype to use (e.g."html"
)
-
setHtmlMessage
Sets the email body (MIME typetext/html
).- Parameters:
message
- the email body in HTML
-
enableTLS
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.Enables 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.As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.Enables 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.As of Jedox 24.2, calling this method has no effect. SMTP settings are now configured in Jedox Cloud Console.Configures 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
public void send() throws com.jedox.etl.components.scriptapi.MailAPI.MailExceptionSends an email once its composition is complete.- Throws:
com.jedox.etl.components.scriptapi.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.As of Jedox 24.2, calling this method returnsnull
. SMTP settings are now configured in Jedox Cloud Console.Returns the SMTP host name.- Returns:
- the SMTP host name
-
getSmtpPort
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method returnsnull
. SMTP settings are now configured in Jedox Cloud Console.Returns the SMTP port.- Returns:
- the SMTP port
-
getSmtpAuthUser
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method returnsnull
. SMTP settings are now configured in Jedox Cloud Console.Returns 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.As of Jedox 24.2, calling this method returnsnull
. SMTP settings are now configured in Jedox Cloud Console.Returns 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.As of Jedox 24.2, calling this method returnsnull
. SMTP settings are now configured in Jedox Cloud Console.Returns 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.As of Jedox 24.2, calling this method returnsnull
. SMTP settings are now configured in Jedox Cloud Console.Returns the email sender (From).- Returns:
- the email sender (From)
-
isTls
Deprecated, for removal: This API element is subject to removal in a future version.As of Jedox 24.2, calling this method returnsfalse
. SMTP settings are now configured in Jedox Cloud Console.Tests 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.As of Jedox 24.2, calling this method returnsfalse
. SMTP settings are now configured in Jedox Cloud Console.Tests 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.As of Jedox 24.2, calling this method returnsfalse
. SMTP settings are now configured in Jedox Cloud Console.Tests 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
-