Class SmtpManager

All Implemented Interfaces:
AutoCloseable

public class SmtpManager extends MailManager
Manager for sending SMTP events.
  • Field Details

    • session

      private final jakarta.mail.Session session
    • buffer

      private final CyclicBuffer<LogEvent> buffer
    • message

      private volatile jakarta.mail.internet.MimeMessage message
    • data

      private final MailManager.FactoryData data
  • Constructor Details

    • SmtpManager

      protected SmtpManager(String name, jakarta.mail.Session session, jakarta.mail.internet.MimeMessage message, MailManager.FactoryData data)
  • Method Details

    • createMimeMessage

      private static jakarta.mail.internet.MimeMessage createMimeMessage(MailManager.FactoryData data, jakarta.mail.Session session, LogEvent appendEvent) throws jakarta.mail.MessagingException
      Throws:
      jakarta.mail.MessagingException
    • add

      public void add(LogEvent event)
      Description copied from class: MailManager
      Adds an event to the cyclic buffer.
      Specified by:
      add in class MailManager
      Parameters:
      event - The event to add.
    • sendEvents

      public void sendEvents(Layout<?> layout, LogEvent appendEvent)
      Description copied from class: MailManager
      Send the contents of the cyclic buffer as an e-mail message.
      Specified by:
      sendEvents in class MailManager
      Parameters:
      layout - The layout for formatting the events.
      appendEvent - The event that triggered the send.
    • removeAllBufferedEvents

      LogEvent[] removeAllBufferedEvents()
    • formatContentToBytes

      protected byte[] formatContentToBytes(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout) throws IOException
      Throws:
      IOException
    • writeContent

      private void writeContent(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout, ByteArrayOutputStream out) throws IOException
      Throws:
      IOException
    • writeHeader

      protected void writeHeader(Layout<?> layout, OutputStream out) throws IOException
      Throws:
      IOException
    • writeBuffer

      protected void writeBuffer(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout, OutputStream out) throws IOException
      Throws:
      IOException
    • writeFooter

      protected void writeFooter(Layout<?> layout, OutputStream out) throws IOException
      Throws:
      IOException
    • getEncoding

      protected String getEncoding(byte[] rawBytes, String contentType)
    • encodeContentToBytes

      protected byte[] encodeContentToBytes(byte[] rawBytes, String encoding) throws jakarta.mail.MessagingException, IOException
      Throws:
      jakarta.mail.MessagingException
      IOException
    • encodeContent

      protected void encodeContent(byte[] bytes, String encoding, ByteArrayOutputStream out) throws jakarta.mail.MessagingException, IOException
      Throws:
      jakarta.mail.MessagingException
      IOException
    • getHeaders

      protected jakarta.mail.internet.InternetHeaders getHeaders(String contentType, String encoding)
    • getMimeMultipart

      protected jakarta.mail.internet.MimeMultipart getMimeMultipart(byte[] encodedBytes, jakarta.mail.internet.InternetHeaders headers) throws jakarta.mail.MessagingException
      Throws:
      jakarta.mail.MessagingException
    • sendMultipartMessage

      @Deprecated protected void sendMultipartMessage(jakarta.mail.internet.MimeMessage msg, jakarta.mail.internet.MimeMultipart mp) throws jakarta.mail.MessagingException
      Deprecated.
      Throws:
      jakarta.mail.MessagingException
    • sendMultipartMessage

      protected void sendMultipartMessage(jakarta.mail.internet.MimeMessage msg, jakarta.mail.internet.MimeMultipart mp, String subject) throws jakarta.mail.MessagingException
      Throws:
      jakarta.mail.MessagingException
    • connect

      private void connect(LogEvent appendEvent)