Class MailService

java.lang.Object
com.apgar.common.lib.mail.MailService

public class MailService extends Object
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 Details

    • getInstance

      public static MailService getInstance(MailSpecif mailSpec)
      Creates a new instance of MailService with 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 in MailSpecif. This method constructs the email message and attempts to send it via the configured mail session using Transport. If a sender email address is not specified, it defaults to the one specified in the email parameters configuration of the workflow administration.
      Returns:
      true if the email was sent successfully; false otherwise.
    • getRepositoryMailSender

      public static String 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

      public static String 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