Skip to content

Provide a native Jakarta Mail Provider SPI #10

Closed

Description

@verhasi

Is your feature request related to a problem?
Currently, to use smtp-connection-pool, developers must adopt the custom SmtpConnectionPool API directly. This prevents developers from using the pool in legacy codebases, Spring JavaMailSender, Apache Camel, or frameworks that rely strictly on standard jakarta.mail.Session and jakarta.mail.Transport.

Describe the solution you'd like
Add a lightweight Jakarta Mail SPI Provider module (e.g., smtp-connection-pool-spi or registering a custom protocol like smtppool in META-INF/javamail.providers).

This module would provide a PooledTransport implementation that extends jakarta.mail.Transport:

  • connect() -> Claims an open connection from SmtpConnectionPool
  • sendMessage() -> Delegates to the leased Transport
  • close() -> Releases the connection back to SmtpConnectionPool

Why this adds value

  1. Zero API Lock-in: Users can configure pooling entirely via standard Session properties (e.g., mail.smtppool.host, mail.smtppool.size).
  2. Drop-in Compatibility: Allows existing applications and third-party frameworks to benefit from smtp-connection-pool without touching business code or replacing Transport.send() / JavaMailSender.
  3. Massive Adoption: Removes the barrier to entry for enterprise applications tied to standard Jakarta Mail APIs.

Activity

  1. bbottema commented on Aug 9, 2026

    @bbottema
    Member

    Maintainer planning outcome for this request:

    • Keep the existing direct smtp-connection-pool API. Higher-level Simple Java Mail remains a deliberate direct integration and will not route its own Mailer through PooledTransport.
    • Add a shared, explicit transport-lease contract in the core so direct integrations and the provider use the same release/invalidate semantics.
    • Add an opt-in Jakarta Mail provider artifact registering smtppool. connect claims a lease, sendMessage delegates, and close releases or invalidates based on the outcome.
    • Resolve the real delegate explicitly as smtp or smtps; never call the Session's default transport from the pooled provider, which could recursively select itself.
    • Add an opt-in Camel adapter that selects smtppool without globally replacing Camel/Jakarta Mail's normal smtp provider.
    • Preserve the existing core GAV and ship the three consumer-facing artifacts as one version-aligned reactor.
    • Treat this as an additive minor release, currently planned as 3.2.0, subject to implementation and separate release approval.

    The organization-level usage model has three paths: direct core integration (including Simple Java Mail internally), standalone use of Simple Java Mail's batch module after it gains a public callback API, and the standard Jakarta Mail facade for plain Jakarta Mail/Spring/Camel.

    The downstream Simple Java Mail and simplejavamail.org work is tracked in bbottema/simple-java-mail#698 and starts only after the upstream release is published.

    Per the maintainer release workflow, the 3.2.0 milestone will be created and dated when a real publication date is scheduled; no tag or release is authorized by this planning comment.

  2. verhasi commented on Aug 10, 2026

    @verhasi
    ContributorAuthor

    Hi Benny,

    Thanks for laying out such a thorough and clear architectural plan for 3.2.0! The 3-tiered model and the recursive selection safeguards make total sense.

    I would be happy to contribute the implementation for the smtp-connection-pool-provider module (the smtppool Jakarta Mail SPI adapter) following your specifications:

    • Registering smtppool in META-INF/javamail.providers.
    • Explicitly delegating to smtp/smtps (avoiding recursive Session default lookups).
    • Integrating with the shared transport-lease contract (connect() claims, sendMessage() executes, close() releases or invalidates based on execution state).

    Please let me know if you'd like me to draft a Pull Request for this module, and if it fits your needs to follow the directions for development at https://github.com/bbottema/simple-java-mail/blob/master/DEVELOPMENT.md!

    Best regards,
    István

  3. added this to the 3.2.0 milestone on Aug 10, 2026
  4. bbottema commented on Aug 10, 2026

    @bbottema
    Member

    Thank you for the offer @verhasi, but it's already implemented :)

    Released in v4.0.0.

    The release publishes:

    The smtppool provider supports plain Jakarta Mail and Spring; Camel uses the separate smtppool: / smtppools: adapter. The existing direct coordinate and Java 8 baseline remain intact. Configuration and runnable examples are linked from the README.

  5. verhasi commented on Aug 11, 2026

    @verhasi
    ContributorAuthor

    Hi Benny,

    It was surprisingly fast, awesome. Were you just waiting behind the bush with already implemented feature in your pocket when will someone come and ask for it? :D
    Than you the fast delivery, I will come back with the experiences of our team.

  6. bbottema commented on Aug 11, 2026

    @bbottema
    Member

    @verhasi, a field-test would be very helpful!

  7. bbottema commented on Aug 11, 2026

    @bbottema
    Member
  8. changed the title [-]Feature Request: Native Jakarta Mail Provider SPI (Drop-in Transport Pool)[/-] [+]Provide a native Jakarta Mail Provider SPI[/+] on Aug 12, 2026
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