Class AbstractMailer

java.lang.Object
ch.autumo.beetroot.mailing.AbstractMailer
All Implemented Interfaces:
Mailer
Direct Known Subclasses:
JakartaMailer, JavaxMailer

public abstract class AbstractMailer extends Object implements Mailer
Abstract mailer class.
  • Field Details

    • DEFAULT_SMTP_PORT

      public static final int DEFAULT_SMTP_PORT
      default SMTP port.
      See Also:
    • mailformats

      protected String[] mailformats
      Mail formats.
    • auth

      protected boolean auth
      Mail authentication?
    • tlsEnable

      protected boolean tlsEnable
      TLS enabled?
    • sslEnable

      protected boolean sslEnable
      SSL enabled?
    • port

      protected int port
      SMTP Port.
    • portStr

      protected String portStr
      SMTP Port string.
    • host

      protected String host
      SMTP Host.
    • pwEncoded

      protected boolean pwEncoded
      Passwords encoded in mail configuration section ('cfg/beetroot.cfg')?
    • user

      protected String user
      Mail user (email).
    • password

      protected String password
      Mail user password.
    • from

      protected String from
      Mail from (email).
  • Constructor Details

    • AbstractMailer

      public AbstractMailer()
  • Method Details

    • initialize

      protected Properties initialize() throws Exception
      Initialize mail configuration; some are store in the returned properties and some attributes are initialized.
      Returns:
      mail configuration
      Throws:
      Exception - if configuration loading fails
    • loadTemplateWithVariables

      protected String loadTemplateWithVariables(String templateName, BeetRootHTTPSession session, Map<String,String> variables, String format) throws Exception
      Load language translated templates with variables replaced.
      Parameters:
      templateName - template name
      session - HTTPS session
      variables - variables
      format - mail format
      Returns:
      replaced template
      Throws:
      Exception
    • loadTemplate

      protected String loadTemplate(String templateName, BeetRootHTTPSession session, String extension) throws Exception
      Load mail template.
      Parameters:
      templateName - template name
      session - HTTP session or null (default language is used)
      extension - template extension (txt or html)
      Returns:
      loaded template as string
      Throws:
      Exception - if an error occurs
    • replaceAllLanguageVariables

      protected String replaceAllLanguageVariables(String template, BeetRootHTTPSession session, String extension)
      Replace language variables in loaded mail template.
      Parameters:
      template - loaded te,plate
      session - HTTP session or null (default language is used)
      extension - template extension (txt or html)
      Returns:
      template with replaced language variables
    • replaceAllVariables

      protected String replaceAllVariables(String template, Map<String,String> variables, String extension)
      Replace general variables in loaded mail template.
      Parameters:
      template - loaded template
      variables - variables to replace
      extension - template extension (txt or html)
      Returns:
      replaced templates
    • mail

      public abstract void mail(String[] to, String subject, Map<String,String> variables, String templateName, BeetRootHTTPSession session) throws Exception
      Specified by:
      mail in interface Mailer
      Parameters:
      to - email receiver addresses
      subject - subject
      variables - variables to parse in templates
      templateName - template name
      session - HTTP session or null if not called within a servlet context (default language used)
      Throws:
      Exception - exception