Class Mailer

    • Field Detail

      • session

        protected volatile javax.mail.Session session
      • auth

        @Deprecated(since="11.1")
        protected javax.mail.Authenticator auth
        Deprecated.
        since 11.1, not used anymore
      • sessionName

        protected final String sessionName
        The JNDI session name. If not null JNDI will be used to lookup the default session, otherwise local configuration (through config) will be used to create a session.
    • Constructor Detail

      • Mailer

        public Mailer​(Properties config)
        Create a mailer that use the given properties to configure the session.
      • Mailer

        public Mailer​(String sessionName)
        Create a mailer using a session that lookup for the session in JNDI under the given session name.
      • Mailer

        public Mailer​(String sessionName,
                      Properties config)
        Create a mailer using a session that lookup for the session in JNDI under the given session name. If the JNDI binding doesn't exists use the given properties to cinfiugure the session.
    • Method Detail

      • setServer

        public void setServer​(String host)
      • setServer

        public void setServer​(String host,
                              boolean ssl)
      • setServer

        public void setServer​(String host,
                              String port)
        Set the SMTP server address to use
      • setServer

        public void setServer​(String host,
                              String port,
                              boolean ssl)
      • setCredentials

        @Deprecated(since="11.1")
        public void setCredentials​(String user,
                                   String pass)
        Deprecated.
        since 11.1, use mail.${protocol}.user and mail.${protocol}.password instead
        Set SMTP credentials.
      • setAuthenticator

        @Deprecated(since="11.1")
        public void setAuthenticator​(javax.mail.Authenticator auth)
        Deprecated.
        since 11.1, this method does nothing, use mail.${protocol}.user and mail.${protocol}.password instead
      • setDebug

        public void setDebug​(boolean debug)
      • getSession

        public javax.mail.Session getSession()
      • getConfiguration

        public Properties getConfiguration()
      • setConfiguration

        public void setConfiguration​(Properties config)
      • send

        public void send​(javax.mail.internet.MimeMessage message)
                  throws javax.mail.MessagingException
        Throws:
        javax.mail.MessagingException
      • sendEmail

        public void sendEmail​(String from,
                              String to,
                              String subject,
                              String body)
                       throws javax.mail.MessagingException
        Send a single email.
        Throws:
        javax.mail.MessagingException