commit | d1bc628296f5d755d3cddba9b6111a8906c12c9d | [log] [tgz] |
---|---|---|
author | Oliver Lietz <olli@apache.org> | Sun Feb 23 01:05:17 2020 +0100 |
committer | Oliver Lietz <olli@apache.org> | Sun Feb 23 01:05:17 2020 +0100 |
tree | 47afb6823560ff67264631c2b65d1b60f4a2a659 | |
parent | 3a098379d587a8d3a3bcdca8ef4ab9aea4291552 [diff] |
SLING-9082 Update to Sling Bundle Parent 38 Switch back from SNAPSHOT to released version
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.
@Reference 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") .replyTo("rocksteady@jamaica.example.net"); .subject(subject) .text(text) .html(html) .attachment(attachment, "image/png", "attachment.png") .inline(inline, "image/png", "inline") .build(); mailService.sendMessage(message);
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.smtps.server.external=true\ -Dsling.test.mail.smtps.from=envelope-from@example.org\ -Dsling.test.mail.smtps.host=localhost\ -Dsling.test.mail.smtps.port=465\ -Dsling.test.mail.smtps.username=username\ -Dsling.test.mail.smtps.password=password\ -Dsling.test.mail.from.address=from@example.org\ -Dsling.test.mail.from.name=From\ Sender\ -Dsling.test.mail.to.address=to@example.org\ -Dsling.test.mail.to.name=To\ Recipient\ -Dsling.test.mail.replyTo.address=replyto@example.org\ -Dsling.test.mail.replyTo.name=Reply\ To