Apache Sling Commons Messaging Mail

Clone this repo:
  1. f9d932d let bnd calculate version of package import for javax.activation by Oliver Lietz · 8 weeks ago master
  2. f536ead use activation bundle on all Java versions by Oliver Lietz · 8 weeks ago
  3. 1ebf149 reverse JDK order by Oliver Lietz · 8 weeks ago
  4. 7b42ae1 remove version from javax.activation package import by Oliver Lietz · 8 weeks ago
  5. 8d222f3 execute integration tests with all JDKs by Oliver Lietz · 8 weeks ago

Build Status Test Status Maven Central JavaDocs License

Apache Sling Commons Messaging Mail

This module is part of the Apache Sling project.

This module provides a simple layer on top of Jakarta Mail (former JavaMail) including a message builder and a service to send mails via SMTPS.

  • Mail Service: sends MIME messages.
  • Message Builder: builds plain text and HTML messages with attachments and inline images
  • Message ID Provider: allows overwriting default message IDs by custom ones


    MailService mailService;

    String subject = "Rudy, A Message to You";
    String text = "Stop your messing around\nBetter think of your future\nTime you straighten right out\nCreating problems in town\n…";
    String html = […];
    byte[] attachment = […];
    byte[] inline = […];

    MimeMessage message = mailService.getMessageBuilder()
        .from("dandy.livingstone@kingston.jamaica.example.net", "Dandy Livingstone")
        .to("the.specials@coventry.england.example.net", "The Specials")
        .attachment(attachment, "image/png", "attachment.png")
        .inline(inline, "image/png", "inline")


Integration Tests

Integration tests require a running SMTP server. By default a GreenMail server is started.

An external SMTP server for validating messages with real mail clients can be used by setting required properties:

mvn clean install\
  -Dsling.test.mail.from.name=From\ Sender\
  -Dsling.test.mail.to.name=To\ Recipient\
  -Dsling.test.mail.replyTo.name=Reply\ To