Package org.apache.logging.log4j.smtp
Class SmtpManager
java.lang.Object
org.apache.logging.log4j.core.appender.AbstractManager
org.apache.logging.log4j.core.net.MailManager
org.apache.logging.log4j.smtp.SmtpManager
- All Implemented Interfaces:
AutoCloseable
Manager for sending SMTP events.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFactory to create the SMTP Manager.Nested classes/interfaces inherited from class org.apache.logging.log4j.core.net.MailManager
MailManager.FactoryDataNested classes/interfaces inherited from class org.apache.logging.log4j.core.appender.AbstractManager
AbstractManager.AbstractFactoryData -
Field Summary
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractManager
count, LOGGER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSmtpManager(String name, jakarta.mail.Session session, jakarta.mail.internet.MimeMessage message, MailManager.FactoryData data) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an event to the cyclic buffer.protected voidencodeContent(byte[] bytes, String encoding, ByteArrayOutputStream out) protected byte[]encodeContentToBytes(byte[] rawBytes, String encoding) protected byte[]formatContentToBytes(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout) protected StringgetEncoding(byte[] rawBytes, String contentType) protected jakarta.mail.internet.InternetHeadersgetHeaders(String contentType, String encoding) protected jakarta.mail.internet.MimeMultipartgetMimeMultipart(byte[] encodedBytes, jakarta.mail.internet.InternetHeaders headers) voidsendEvents(Layout<?> layout, LogEvent appendEvent) Send the contents of the cyclic buffer as an e-mail message.protected voidsendMultipartMessage(jakarta.mail.internet.MimeMessage msg, jakarta.mail.internet.MimeMultipart mp) Deprecated.protected voidsendMultipartMessage(jakarta.mail.internet.MimeMessage msg, jakarta.mail.internet.MimeMultipart mp, String subject) protected voidwriteBuffer(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout, OutputStream out) protected voidwriteFooter(Layout<?> layout, OutputStream out) protected voidwriteHeader(Layout<?> layout, OutputStream out) Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
close, getContentFormat, getCount, getLoggerContext, getManager, getName, getStrSubstitutor, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, releaseSub, stop, updateData
-
Constructor Details
-
SmtpManager
protected SmtpManager(String name, jakarta.mail.Session session, jakarta.mail.internet.MimeMessage message, MailManager.FactoryData data)
-
-
Method Details
-
add
Description copied from class:MailManagerAdds an event to the cyclic buffer.- Specified by:
addin classMailManager- Parameters:
event- The event to add.
-
sendEvents
Description copied from class:MailManagerSend the contents of the cyclic buffer as an e-mail message.- Specified by:
sendEventsin classMailManager- Parameters:
layout- The layout for formatting the events.appendEvent- The event that triggered the send.
-
formatContentToBytes
protected byte[] formatContentToBytes(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout) throws IOException - Throws:
IOException
-
writeHeader
- Throws:
IOException
-
writeBuffer
protected void writeBuffer(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout, OutputStream out) throws IOException - Throws:
IOException
-
getEncoding
-
encodeContentToBytes
protected byte[] encodeContentToBytes(byte[] rawBytes, String encoding) throws jakarta.mail.MessagingException, IOException - Throws:
jakarta.mail.MessagingExceptionIOException
-
encodeContent
protected void encodeContent(byte[] bytes, String encoding, ByteArrayOutputStream out) throws jakarta.mail.MessagingException, IOException - Throws:
jakarta.mail.MessagingExceptionIOException
-
getHeaders
-
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.Please use thesendMultipartMessage(MimeMessage, MimeMultipart, String)method instead.- 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
-
sendMultipartMessage(MimeMessage, MimeMultipart, String)method instead.