Class SMTPAppenderBase<E>

  • All Implemented Interfaces:
    Appender<E>, ContextAware, FilterAttachable<E>, LifeCycle
    Direct Known Subclasses:

    public abstract class SMTPAppenderBase<E>
    extends AppenderBase<E>
    An abstract class that provides support for sending events to an email address.

    See for further documentation.

    • Constructor Detail

      • SMTPAppenderBase

        public SMTPAppenderBase()
    • Method Detail

      • checkEntryConditions

        public boolean checkEntryConditions()
        This method determines if there is a sense in attempting to append.

        It checks whether there is a set output target and also if there is a set layout. If these checks fail, then the boolean value false is returned.

      • getFrom

        public String getFrom()
        Returns value of the From option.
      • getSubject

        public String getSubject()
        Returns value of the Subject option.
      • setFrom

        public void setFrom​(String from)
        The From option takes a string value which should be a e-mail address of the sender.
      • setSubject

        public void setSubject​(String subject)
        The Subject option takes a string value which should be a the subject of the e-mail message.
      • setSMTPHost

        public void setSMTPHost​(String smtpHost)
        Alias for smtpHost
        smtpHost -
      • setSmtpHost

        public void setSmtpHost​(String smtpHost)
        The smtpHost option takes a string value which should be a the host name of the SMTP server that will send the e-mail message.
      • getSMTPHost

        public String getSMTPHost()
        Alias for getSmtpHost().
      • getSmtpHost

        public String getSmtpHost()
        Returns value of the SMTPHost option.
      • setSMTPPort

        public void setSMTPPort​(int port)
        Alias for setSmtpPort(int).
        port -
      • setSmtpPort

        public void setSmtpPort​(int port)
        The port where the SMTP server is running. Default value is 25.
        port -
      • getSMTPPort

        public int getSMTPPort()
        Alias for getSmtpPort()
      • getLocalhost

        public String getLocalhost()
      • setLocalhost

        public void setLocalhost​(String localhost)
        Set the "mail.smtp.localhost" property to the value passed as parameter to this method.

        Useful in case the hostname for the client host is not fully qualified and as a consequence the SMTP server rejects the clients HELO/EHLO command.

        localhost -
      • setDiscriminator

        public void setDiscriminator​(Discriminator<E> discriminator)
      • isAsynchronousSending

        public boolean isAsynchronousSending()
      • setAsynchronousSending

        public void setAsynchronousSending​(boolean asynchronousSending)
        By default, SMTAppender transmits emails asynchronously. For synchronous email transmission set asynchronousSending to 'false'.
        asynchronousSending - determines whether sending is done asynchronously or not
      • addTo

        public void addTo​(String to)
      • getToAsListOfString

        public List<String> getToAsListOfString()
      • isSTARTTLS

        public boolean isSTARTTLS()
      • setSTARTTLS

        public void setSTARTTLS​(boolean startTLS)
      • isSSL

        public boolean isSSL()
      • setSSL

        public void setSSL​(boolean ssl)
      • setEvaluator

        public void setEvaluator​(EventEvaluator<E> eventEvaluator)
        The EventEvaluator option takes a string value representing the name of the class implementing the EventEvaluator interface. A corresponding object will be instantiated and assigned as the event evaluator for the SMTPAppender.
      • getUsername

        public String getUsername()
      • setUsername

        public void setUsername​(String username)
      • getPassword

        public String getPassword()
      • setPassword

        public void setPassword​(String password)
      • getJndiLocation

        public String getJndiLocation()
      • setJndiLocation

        public void setJndiLocation​(String jndiLocation)
        Set the location where a Session resource is located in JNDI. Default value is "java:comp/env/mail/Session".
        jndiLocation -
      • isSessionViaJNDI

        public boolean isSessionViaJNDI()
      • setSessionViaJNDI

        public void setSessionViaJNDI​(boolean sessionViaJNDI)
        If set to true, a Session resource will be retrieved from JNDI. Default is false.
        sessionViaJNDI - whether to obtain a javax.mail.Session by JNDI
      • setCharsetEncoding

        public void setCharsetEncoding​(String charsetEncoding)
        Set the character set encoding of the outgoing email messages. The default encoding is "UTF-8" which usually works well for most purposes.
        charsetEncoding -
      • getLayout

        public Layout<E> getLayout()
      • setLayout

        public void setLayout​(Layout<E> layout)