1- Spring Boot DKIM JavaMail
2- ===
1+ # Spring Boot Mail Extensions
32
4- This project provides an easy way to digitally sign your emails. Therefore, this project uses the
5- [ java-utils-mail-dkim] ( https://github.com/markenwerk/java-utils-mail-dkim ) library from Markenwerk and extends Spring's
6- JavaMailSender to sign MIME messages before they were transported to the SMTP server. To verify the signed parts of the
7- email you must configure your DNS. This authentication method is called DKIM (DomainKeys Identified Mail).
3+ This project aims to extend Spring's ` JavaMailSender ` with useful features. Therefore, the library provides two advanced
4+ sender extensions. Library and starters are compatible with Spring Framework >5.2.x and Spring Boot >2.2.x
5+
6+
7+ ## Library
8+
9+ The library currently provides two combinable sender implementations.
10+
11+ The ` DkimJavaMailSender ` uses Markenwerk's [ java-utils-mail-dkim] ( https://github.com/markenwerk/java-utils-mail-dkim )
12+ library and extends Spring's ` JavaMailSender ` to sign MIME messages before they were transported to the SMTP server. To
13+ verify the signed parts of the email you must configure your DNS. This authentication method is called ** DKIM**
14+ (DomainKeys Identified Mail). In case you are not using the starter, you must configure the ` DkimSigner ` yourself.
15+
16+ The ` ConcurrentJavaMailSender ` enqueues any supported MIME message to be sent immediately or after a configurable
17+ cooldown. By splitting potential large amounts of messages into smaller batches your application is capable of ** dealing
18+ with** common problems or restrictions of your SMTP server or provider, like ** rate limits** . The dispatch happens on
19+ another thread, so you don't block your main thread in case of a ** slow SMTP server** .
820
921
1022## Usage
1123
12- Include the ` spring-boot-starter-dkim-javamail ` dependency in your ` pom.xml ` and adjust your ` application.properties ` or
13- ` application.yml ` as described in [ Configuration] ( #Configuration ) .
24+ This project provides 4 artifacts. Depending on your scope and infrastructure you may want just the library. Include
25+ the ` mail-extensions ` and ` utils-mail-dkim ` libraries in your Spring Project ** in case you don't want or can use the
26+ Starters** . Adjust your ` pom.xml ` as followed:
27+
28+ ``` xml
29+ <dependency >
30+ <groupId >de.vinado.spring</groupId >
31+ <artifactId >mail-extensions</artifactId >
32+ <version >2.0.0</version >
33+ </dependency >
34+ <dependency >
35+ <groupId >net.markenwerk</groupId >
36+ <artifactId >utils-mail-dkim</artifactId >
37+ <version >1.4.0</version >
38+ </dependency >
39+ ```
40+
41+ ---
42+
43+ Those who use Spring Boot can choose between 3 Spring Boot starters.
44+
45+ 1 . ` mail-extensions-concurrent-javamail-spring-boot-starter `
46+ 2 . ` mail-extensions-dkim-javamail-spring-boot-starter `
47+ 3 . ` mail-extensions-all-spring-boot-starter `
48+
49+ Include one of the above in your ` pom.xml ` and adjust your ` application.properties ` or ` application.yml ` as described in
50+ [ Configuration] ( #Configuration ) .
1451
1552The starter, as well as the other artifacts are hosted in the
16- [ Maven Central Repository] ( https://search.maven.org/artifact/de.vinado.boot/spring-boot-starter-dkim-javamail/1.2.2/jar ) .
17- You can use it with the following coordinates:
53+ [ Maven Central Repository] ( https://search.maven.org/artifact/de.vinado.boot/mail-extensions-spring-boot/2.0.0/pom ) .
54+ You can use it with one of the following coordinates:
1855
1956``` xml
2057<dependency >
2158 <groupId >de.vinado.boot</groupId >
22- <artifactId >spring-boot-starter-dkim-javamail</artifactId >
23- <version >1.2.2</version >
59+ <artifactId >mail-extensions-concurrent-javamail-spring-boot-starter</artifactId >
60+ <version >2.0.0</version >
61+ </dependency >
62+
63+ <dependency >
64+ <groupId >de.vinado.boot</groupId >
65+ <artifactId >mail-extensions-dkim-javamail-spring-boot-starter</artifactId >
66+ <version >2.0.0</version >
67+ </dependency >
68+
69+ <dependency >
70+ <groupId >de.vinado.boot</groupId >
71+ <artifactId >mail-extensions-all-spring-boot-starter</artifactId >
72+ <version >2.0.0</version >
2473</dependency >
2574```
2675
27- Version ` v1.0.0 ` is still available in the
28- [ JitPack repository ] ( https://jitpack.io/#V1ncNet/spring-boot-dkim-javamail/v1.0.0 ) .
76+ Version ` v1.x ` is still available in an archived [ Git repository ] ( https://github.com/V1ncNet/spring-boot-dkim-javamail ) .
77+
2978
3079## Setup
3180
@@ -37,32 +86,43 @@ setup instructions on how to create an RSA keypair and properly configure DNS.
3786
3887### Configuration
3988
40- The starter uses auto configuration to avoid Java-based adjustments. The mandatory configuration looks like this:
89+ The starter uses autoconfiguration to avoid Java-based adjustments. The mandatory configuration looks like this:
4190
4291``` properties
43- dkim.signing-domain =domain.tld
44- dkim.selector =default
45- dkim.private-key =file:/path/to/your/private.key.der
46- # dkim.private-key=classpath:/path/to/your/private.key.der
47- # dkim.private-key=/path/to/your/private.key.der
92+ javamail.dkim.signing-domain =domain.tld
93+ javamail.dkim.selector =default
94+ javamail.dkim.private-key =file:/path/to/your/private.key.der
95+ # javamail.dkim.private-key=classpath:/path/to/your/private.key.der
4896```
4997
5098The example assumes your TXT record uses the domain ` default._domainkey.domain.tld ` . The following example contains
5199optional properties which configures the DKIM signer itself:
52100
53101``` properties
54- dkim.signer.identity =
55- dkim.signer.header-canonicalization =SIMPLE
56- dkim.signer.body-canonicalization =RELAXED
57- dkim.signer.signing-algorithm =SHA256_WITH_RSA
58- dkim.signer.length-param =true
59- dkim.signer.copy-header-fields =false
60- dkim.signer.check-domain-key =true
102+ javamail. dkim.signer.identity =
103+ javamail. dkim.signer.header-canonicalization =SIMPLE
104+ javamail. dkim.signer.body-canonicalization =RELAXED
105+ javamail. dkim.signer.signing-algorithm =SHA256_WITH_RSA
106+ javamail. dkim.signer.length-param =true
107+ javamail. dkim.signer.copy-header-fields =false
108+ javamail. dkim.signer.check-domain-key =true
61109```
62110
63111To learn more about the identity and canonicalization read the [ specification] ( https://tools.ietf.org/html/rfc6376 )
64112about DKIM.
65113
114+ ---
115+
116+ The concurrent sender can be configured as follows. This sender is deactivated by default.
117+
118+ ``` properties
119+ javamail.concurrent.enabled =true
120+ javamail.concurrent.batch-size =20
121+ # 20 seconds cooldown
122+ javamail.concurrent.cooldown-millis =20000
123+ ```
124+
125+
66126## Licence
67127
68128Apache License 2.0 - [ Vinado] ( https://vinado.de ) - Built with :heart : in Dresden
0 commit comments