Skip to content

Add option to configure smtp debug printer #589

Closed

Description

@michal-krajewski

Hello!
The default behaviour of Jakarta Mail is to push smtp debug logs to std out. It's not a viable solution for my use case; I need to redirect these logs to the Slf4j logger.
To achieve that, I'm accessing Session object directly and setting a custom printer:
mailer.getSession().setDebugOut(new Slf4jPrinter(logger));
(the printer is my custom implementation)

Enhancement:
Allow configuring the debug printer directly in the configuration
.withDebugPrinter(printer)

Activity

  1. added this to the 8.13.0 milestone on Jul 4, 2026
  2. bbottema commented on Jul 4, 2026

    @bbottema
    Owner

    Implemented in by adding configurable Jakarta Mail debug output handling.

    Java builder, using the built-in SLF4J target:

    Mailer mailer = MailerBuilder
        .withSMTPServer("smtp.example.com", 587, "user", "secret")
        .withDebugLogging(true)
        .withDebugOutput(SessionDebugOutput.SLF4J)
        .buildMailer();

    Properties-only configuration:

    simplejavamail.javaxmail.debug=true
    simplejavamail.javaxmail.debug.out=SLF4J

    Spring Boot style alias:

    simplejavamail.javaxmail.debug=true
    simplejavamail.javaxmail.debug-out=SLF4J

    Custom Java printer remains available:

    Mailer mailer = MailerBuilder
        .withSMTPServer("smtp.example.com", 587, "user", "secret")
        .withDebugLogging(true)
        .withDebugPrinter(new Slf4jPrinter(logger))
        .buildMailer();

    Built-in values are STDOUT, STDERR, and SLF4J. The SLF4J target writes to logger org.simplejavamail.javamail.debug at debug level.

  3. bbottema commented on Jul 8, 2026

    @bbottema
    Owner

    Released in Simple Java Mail v9.0.0, which is now available from Maven Central:

    https://repo1.maven.org/maven2/org/simplejavamail/simple-java-mail/9.0.0/

    Release notes:
    https://github.com/bbottema/simple-java-mail/releases/tag/9.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions