-
-
Notifications
You must be signed in to change notification settings - Fork 274
Closed
Labels
Milestone
Description
hi.
I've found a serious bug in the DKIM authentication process.
This is the typical flow for sending mail
- An internal messageId is generated and applied via
fixingMessageId()
currentEmailBuilder.fixingMessageId("<123@456>");
- DKIM configuration is performed for security enhancement
currentEmailBuilder.signWithDomainKey(
DkimConfig.builder()
.dkimPrivateKeyData(byte[] / File / InputStream)
.dkimSigningDomain("your_domain.org")
.dkimSelector("your_selector")
.build()
);
- The email is sent
mailer.sendMail(email);
However, after step 3, the messageId value inside the email object is changed, even though the messageId was fixed in step 1.
The cause of the issue is the following line of code
message.saveChanges()
Here, the messageId is changed by calling message.saveChanges()
.
In any case, the messageId inside the email object should not be changed if it already exists.
There are two possible solutions
- Restore the messageId inside the message object to its original value after calling
message.saveChanges()
. - If the messageId already exists, do not call
message.saveChanges()
.
(There is no need to unnecessarily call saveChanges on the mimeMessage created by convertMimeMessage.)
The second solution seems to be the best