You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2021/05/19 09:18:59 UTC

[sling-org-apache-sling-commons-messaging-mail] branch master updated (a1458a1 -> 395d164)

This is an automated email from the ASF dual-hosted git repository.

olli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-messaging-mail.git.


    from a1458a1  style
     new 40569d5  SLING-10389 Remove Commons Lang3 dependency
     new 395d164  add configuration examples and dependencies

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 README.md                                          | 49 ++++++++++++++++++++--
 pom.xml                                            |  6 ---
 .../messaging/mail/internal/SimpleMailService.java |  5 +--
 .../messaging/mail/it/tests/MailTestSupport.java   |  3 +-
 4 files changed, 48 insertions(+), 15 deletions(-)

[sling-org-apache-sling-commons-messaging-mail] 02/02: add configuration examples and dependencies

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-messaging-mail.git

commit 395d16416a5a35d9e632e6b0ceaae2bc5d06872f
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Wed May 19 11:18:41 2021 +0200

    add configuration examples and dependencies
---
 README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 45 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 89a0cb9..1b9943b 100644
--- a/README.md
+++ b/README.md
@@ -8,12 +8,47 @@ This module is part of the [Apache Sling](https://sling.apache.org) project.
 
 This module provides a simple layer on top of [Jakarta Mail](https://eclipse-ee4j.github.io/mail/) 2.0 (package `jakarta.mail`) including a message builder and a service to send mails via SMTPS.
 
-* Mail Service: sends MIME messages.
+* 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
 
 
-## Example
+## Examples
+
+### Configuration
+
+
+#### MailService
+
+Example factory configuration ([`SimpleMailServiceConfiguration`](https://github.com/apache/sling-org-apache-sling-commons-messaging-mail/blob/master/src/main/java/org/apache/sling/commons/messaging/mail/internal/SimpleMailServiceConfiguration.java)) for [`SimpleMailService`](https://github.com/apache/sling-org-apache-sling-commons-messaging-mail/blob/master/src/main/java/org/apache/sling/commons/messaging/mail/internal/SimpleMailService.java):
+
+```
+{
+  "mail.smtps.from": "envelope-from@example.org",
+  "mail.smtps.host": "smtp.example.org",
+  "mail.smtps.port": 465,
+  "username": "SMTP-USERNAME-PLAIN",
+  "password": "SMTP-PASSWORD-ENCRYPTED",
+  "messageIdProvider.target": "(names=hostname)"
+}
+```
+
+#### Optional MessageIdProvider
+
+Example factory configuration ([`SimpleMessageIdProviderConfiguration`](https://github.com/apache/sling-org-apache-sling-commons-messaging-mail/blob/master/src/main/java/org/apache/sling/commons/messaging/mail/internal/SimpleMessageIdProviderConfiguration.java)) for optional [`SimpleMessageIdProvider`](https://github.com/apache/sling-org-apache-sling-commons-messaging-mail/blob/master/src/main/java/org/apache/sling/commons/messaging/mail/internal/SimpleMessageIdProvider.java):
+
+```
+{
+  "names": [
+    "hostname"
+  ],
+  "host": "author.cms.example.org"
+}
+```
+
+### Usage
+
+Create a multipart MIME message with an attachment (`filename`: `song.flac`) where the HTML part contains an inline image (`cid`: `ska`) and send it:
 
 ```
     @Reference
@@ -32,13 +67,19 @@ This module provides a simple layer on top of [Jakarta Mail](https://eclipse-ee4
         .subject(subject)
         .text(text)
         .html(html)
-        .attachment(attachment, "image/png", "attachment.png")
-        .inline(inline, "image/png", "inline")
+        .attachment(attachment, "audio/flac", "song.flac")
+        .inline(inline, "image/png", "ska")
         .build();
 
     mailService.sendMessage(message);
 ```
 
+## Dependencies
+
+* [Sling Commons Messaging](https://github.com/apache/sling-org-apache-sling-commons-messaging) (API)
+* [Sling Commons Crypto](https://github.com/apache/sling-org-apache-sling-commons-crypto) (for decrypting encrypted SMTP passwords)
+* [Sling Commons Threads](https://github.com/apache/sling-org-apache-sling-commons-threads)
+* [Jakarta Mail 2.0](https://jakarta.ee/specifications/mail/2.0/) and [Jakarta Activation 2.0](https://jakarta.ee/specifications/activation/2.0/) (*OSGified*, e.g. `org.apache.servicemix.specs.activation-api-2.0.1`)
 
 ## Integration Tests
 

[sling-org-apache-sling-commons-messaging-mail] 01/02: SLING-10389 Remove Commons Lang3 dependency

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-messaging-mail.git

commit 40569d5332e82ab6f35b0f996336c1529f45cbf2
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Wed May 19 10:53:52 2021 +0200

    SLING-10389 Remove Commons Lang3 dependency
---
 pom.xml                                                             | 6 ------
 .../sling/commons/messaging/mail/internal/SimpleMailService.java    | 5 ++---
 .../sling/commons/messaging/mail/it/tests/MailTestSupport.java      | 3 +--
 3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/pom.xml b/pom.xml
index 08057c4..0d1eff7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -173,12 +173,6 @@
       <version>2.8.0</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-lang3</artifactId>
-      <version>3.9</version>
-      <scope>provided</scope>
-    </dependency>
     <!-- Apache Felix -->
     <dependency>
       <groupId>org.apache.felix</groupId>
diff --git a/src/main/java/org/apache/sling/commons/messaging/mail/internal/SimpleMailService.java b/src/main/java/org/apache/sling/commons/messaging/mail/internal/SimpleMailService.java
index 348e9e4..7dc2ed1 100644
--- a/src/main/java/org/apache/sling/commons/messaging/mail/internal/SimpleMailService.java
+++ b/src/main/java/org/apache/sling/commons/messaging/mail/internal/SimpleMailService.java
@@ -30,7 +30,6 @@ import jakarta.mail.event.ConnectionListener;
 import jakarta.mail.event.TransportListener;
 import jakarta.mail.internet.MimeMessage;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.commons.crypto.CryptoService;
 import org.apache.sling.commons.messaging.MessageService;
 import org.apache.sling.commons.messaging.mail.MailService;
@@ -151,8 +150,8 @@ public class SimpleMailService implements MailService {
         threadPool = threadPoolManager.get(configuration.threadpool_name());
 
         final Properties properties = new Properties();
-        final String from = configuration.mail_smtps_from();
-        if (StringUtils.isNotBlank(from)) {
+        final String from = configuration.mail_smtps_from().trim();
+        if (!from.isEmpty()) {
             properties.setProperty(MAIL_SMTPS_FROM, from);
         }
 
diff --git a/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java b/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java
index b97fbe5..002c589 100644
--- a/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java
+++ b/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java
@@ -67,7 +67,6 @@ public abstract class MailTestSupport extends TestSupport {
             mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.commons.messaging").versionAsInProject(),
             mavenBundle().groupId("org.apache.servicemix.specs").artifactId("org.apache.servicemix.specs.activation-api-2.0.1").versionAsInProject(),
             mavenBundle().groupId("com.sun.mail").artifactId("jakarta.mail").versionAsInProject(),
-            mavenBundle().groupId("org.apache.commons").artifactId("commons-lang3").versionAsInProject(),
             scr(),
             slingCommonsCrypto(),
             slingCommonsThreads(),
@@ -110,7 +109,7 @@ public abstract class MailTestSupport extends TestSupport {
     private static ModifiableCompositeOption slingCommonsCrypto() {
         return composite(
             mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.commons.crypto").versionAsInProject(),
-            mavenBundle().groupId("org.apache.commons").artifactId("commons-lang3").versionAsInProject(),
+            mavenBundle().groupId("org.apache.commons").artifactId("commons-lang3").version(SlingOptions.versionResolver),
             mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.jasypt").versionAsInProject()
         );
     }