sidhantmourya commented on issue #3704: URL: https://github.com/apache/logging-log4j2/issues/3704#issuecomment-3084605338
Hi @ppkarwasz, After reading through the documentation, I've updated the header handling to properly encode and fold values per RFC 5322 requirements. The current implementation uses MimeUtility to ensure ASCII-only content with proper line length limits. ``` for (Property header : headers) { String value = MimeUtility.fold(78, MimeUtility.encodeText(substitutor.replace(header.getValue()))); setHeader.invoke(message, header.getName(), value); } ``` I'm now looking at how to implement PatternLayout support for headers similar to how SubjectSerializer works. ``` PatternLayout.java final Serializer subjectSerializer = PatternLayout.newSerializerBuilder() .setConfiguration(getConfiguration()) .setPattern(subject) .build(); ``` The issue is that while there's only one subject per email, there can be multiple headers each with their own potential patterns. Looking at the SMTPAppender test case in , I see subjects can contain patterns like "%X{key}", but I'm unsure how to properly extend this to multiple headers. ``` @Test void testDelivery() { final String subjectKey = getClass().getName(); final String subjectValue = "SubjectValue1"; ThreadContext.put(subjectKey, subjectValue); final int smtpPort = AvailablePortFinder.getNextAvailable(); final SmtpAppender appender = SmtpAppender.newBuilder() .setName("Test") .setTo("t...@example.com") .setCc("c...@example.com") .setBcc("b...@example.com") .setFrom("f...@example.com") .setReplyTo("repl...@example.com") .setSubject("Subject Pattern %X{" + subjectKey + "} %maxLen{%m}{10}") .setSmtpHost(HOST) .setSmtpPort(smtpPort) .setBufferSize(3) .build(); assertNotNull(appender); assertInstanceOf(SmtpManager.class, appender.getManager()); appender.start(); ... } ``` I went through the documentation and found this https://logging.apache.org/log4j/2.x/manual/pattern-layout.html#plugin-attr-header. Are there any existing examples in the codebase of similar multi-pattern handling that I could follow? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org