Package com.apgar.common.lib.mail
Class MailService
java.lang.Object
com.apgar.common.lib.mail.MailService
Provides functionality to send emails using SMTP configuration defined in the environment variables or in the EBX properties file. It
handles the construction of email messages, including recipients, subject, body content, and attachments.
Note that this service supports both authenticated and unauthenticated SMTP sessions.
- Author:
- APGAR Consulting
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringRetrieves the URL defined in the workflow configuration for email settings.static MailServicegetInstance(MailSpecif mailSpec) Creates a new instance ofMailServicewith the specified mail specifications.static StringRetrieves the sender email address configured for the workflow in the workflow administration settings.booleansendMail()Sends an email using the specifications provided inMailSpecif.
-
Method Details
-
getInstance
Creates a new instance ofMailServicewith the specified mail specifications.- Parameters:
mailSpec- the specifications for the mail to be sent- Returns:
- an instance of
MailService
-
sendMail
public boolean sendMail()Sends an email using the specifications provided inMailSpecif. This method constructs the email message and attempts to send it via the configured mail session usingTransport. If a sender email address is not specified, it defaults to the one specified in the email parameters configuration of the workflow administration.- Returns:
trueif the email was sent successfully;falseotherwise.
-
getRepositoryMailSender
Retrieves the sender email address configured for the workflow in the workflow administration settings.This method fetches the value from the emailFrom field located in the Email Parameters configuration in Workflows under Workflow Management in Administration.
- Returns:
- the sender email address
-
getEbxServerUrlForMail
Retrieves the URL defined in the workflow configuration for email settings.This URL is used to build links and value mail variables in the workflow (e.g., http://localhost:8080/ebx/)
This method fetches the value from the urlDefinition field field located in the Email Parameters configuration in Workflows under Workflow Management in Administration.
- Returns:
- the email configuration URL
-