Skip to content

Performance: Add default DKIM configuration to MailerBuilder and performance improvement #196

Closed

Description

@bbottema

There's something to be said for avoiding a performance hit by moving the DKIM construction to the MailerBuilder so this is done only once rather than for each separate email.

Original suggestion by @koen-serry

Activity

  1. added this to the 6.0.1 milestone on Oct 12, 2019
  2. modified the milestones: 6.0.1, 6.1.0 on Mar 20, 2020
  3. modified the milestones: 6.2.0, on Jul 10, 2020
  4. bbottema commented on Jun 1, 2021

    @bbottema
    OwnerAuthor

    I've refactored the library a little bit so that there now is a special config group on the Mailer level. Email validation criteria moved there and I've added default S/MIME signing in there as well. Next step would be to finally add default DKIM signing in there as well. Will work on this soon.

  5. changed the title [-]Consider moving the DKIM configuration from EmailBuilder to MailerBuilder[/-] [+]Add default DKIM configuration to MailerBuilder and performance improvement[/+] on Jun 1, 2021
  6. modified the milestones: , 7.0.0 on Jun 12, 2021
  7. removed this from the 7.0.0 milestone on Jan 2, 2022
  8. changed the title [-]Add default DKIM configuration to MailerBuilder and performance improvement[/-] [+]Performance: Add default DKIM configuration to MailerBuilder and performance improvement[/+] on Feb 23, 2023
  9. added this to the 9.0.0 milestone on Jul 4, 2026
  10. bbottema commented on Jul 4, 2026

    @bbottema
    OwnerAuthor

    Fixed by 0eb14398.

    Default DKIM signing can now be configured once on the MailerBuilder, so individual emails no longer need to rebuild or carry the same DKIM configuration unless they intentionally override it.

    DkimConfig dkimConfig = DkimConfig.builder()
        .dkimPrivateKeyData(Files.readAllBytes(Paths.get("dkim-private.der")))
        .dkimSigningDomain("example.com")
        .dkimSelector("mail")
        .build();
    
    Mailer mailer = MailerBuilder
        .withSMTPServer("smtp.example.com", 587, username, password)
        .withTransportStrategy(TransportStrategy.SMTP_TLS)
        .withDefaultDkimSigning(dkimConfig)
        .buildMailer();
    
    mailer.sendMail(EmailBuilder.startingBlank()
        .from("sender@example.com")
        .to("recipient@example.com")
        .withSubject("Signed by default")
        .withPlainText("This email uses the mailer-level DKIM default.")
        .buildEmail());

    Email-specific DKIM still wins when an email calls signWithDomainKey(...), and property-driven DKIM remains available through simplejavamail.dkim.signing.*.

  11. added a commit that references this issue on Jul 4, 2026
    0eb1439
  12. bbottema commented on Jul 8, 2026

    @bbottema
    OwnerAuthor
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