Comments (11)
Thank you for your report. Can you please provide evidence that this is not working? fixingMessageId is specifically made for this kind of situation and has been a core feature for many years. When message.saveChanges()
is called, the following override is triggered:
MimeMessage message = new MimeMessage(session) {
@Override
protected void updateMessageID() throws MessagingException {
if (valueNullOrEmpty(email.getId())) {
super.updateMessageID();
} else {
setHeader("Message-ID", email.getId());
}
}
...
};
This is also extensively automatically tested using a real (but for testing) SMTP server (in MailerLiveTest.java).
However, it's possibly a regression bug, but then I would expect the tests to fail on this feature.
from simple-java-mail.
I see the confusion you're having now.
I think I may have caused confusion due to my inadequate explanation
Please take a look at the code a bit further down.
When returning through ModuleLoader, MimeMessage is overridden again. This means that when using features such as Smime or Dkim, MimeMessage is overridden again. code
if (email.getPkcs12ConfigForSmimeSigning() != null) {
message = ModuleLoader.loadSmimeModule().signMessageWithSmime(session, message, email.getPkcs12ConfigForSmimeSigning());
}
if (email.getX509CertificateForSmimeEncryption() != null) {
message = ModuleLoader.loadSmimeModule().encryptMessageWithSmime(session, message, email.getX509CertificateForSmimeEncryption());
}
if (email.getDkimConfig() != null) {
message = ModuleLoader.loadDKIMModule().signMessageWithDKIM(message, email.getDkimConfig(), checkNonEmptyArgument(email.getFromRecipient(), "fromRecipient"));
}
if (email.getBounceToRecipient() != null) {
// display name not applicable: https://tools.ietf.org/html/rfc5321#section-4.1.2
message = new ImmutableDelegatingSMTPMessage(message, email.getBounceToRecipient().getAddress());
}
In other words, if use the Dkim feature, the overriding of the updateMessageID method above becomes useless.
from simple-java-mail.
DKIMSigner. signMessageWithDKIM(...)
....
return new DkimMessage(messageToSign, dkimSigner);
DkimMessage (in utils-mail-dkim-3.0.0.jar)
public class DkimMessage extends SMTPMessage {
private static byte[] NL = { (byte) '\r', (byte) '\n' };
private DkimSigner signer;
private String encodedBody;
/**
* Created a new {@code DkimMessage} from the given {@link MimeMessage} and
* {@link DkimSigner}.
*
* @param message
* The {@link MimeMessage} to be signed.
* @param signer
* The {@link DkimSigner} to sign the message with.
* @throws MessagingException
* If constructing this {@code DkimMessage} failed.
*/
public DkimMessage(MimeMessage message, DkimSigner signer) throws MessagingException {
super(message);
this.signer = signer;
}
...
DkimMessage is the result of extending Jakarta MimeMessage.
There is no updated version of 'updateMessageId(..)' that you have redefined here.
It simply creates a new messageId unconditionally.
protected void updateMessageID() throws MessagingException {
setHeader("Message-ID",
"<" + UniqueValue.getUniqueMessageIDValue(session) + ">");
}
from simple-java-mail.
Oh wauw, that's a nice find! I'll see about reproducing this in my tests so that's covered. I'll fix this, but I'm not sure how fast. Might be a week or two.
Thank you for bringing this to my attention.
from simple-java-mail.
Thank you for taking the time to fix the bug.
I hope to see the issue resolved quickly. 👍
from simple-java-mail.
@bbottema
Are there any updates?
from simple-java-mail.
Fix released in v8.1.1. Can you please verify?
from simple-java-mail.
Just if someone else experience a java.lang.ClassNotFoundException: org.simplejavamail.internal.dkimsupport.DkimMessageIdFixingMimeMessage
. Up to now, I used nothing from the dkim-module dependency and therefore haven't listed it in my pom. But with this update the dkim-module is required for the runtime otherwise the above exception is thrown when sending signed emails with S/MIME. Error does not occur on compile time.
from simple-java-mail.
Yikes, you're right! I already know why it happens, but a quick work around is indeed to have both dkim and s/mime moduled on the classpath. I'll send out a fix ASAP.
Thank you so much for bringing this to our attention.
from simple-java-mail.
Just if someone else experience a
java.lang.ClassNotFoundException: org.simplejavamail.internal.dkimsupport.DkimMessageIdFixingMimeMessage
. Up to now, I used nothing from the dkim-module dependency and therefore haven't listed it in my pom. But with this update the dkim-module is required for the runtime otherwise the above exception is thrown when sending signed emails with S/MIME. Error does not occur on compile time.
Fixed in v8.1.2!
from simple-java-mail.
You are great. Super quick fix! I can confirm, it works as before (without dkim-module dep).
from simple-java-mail.
Related Issues (20)
- [bug] Attachment body parts should separately parse Content-Disposition and ContentID, possible resulting in an downloadable attachment that is also embedded HOT 9
- [bug] don't require smime-module when adding collection of headers (also used when copying email) HOT 2
- [question from newbie] sjm cli does not return HOT 1
- Add config support for 'verifyingServerIdentity' with SMTP, also: since Angus 1.1.0 (8.6.0) server identity checks are on by default and can be countered by `mailerBuilder.verifyingServerIdentity(false)` HOT 12
- Cannot send an email. HOT 3
- Order of attachments is lost when converting a MimeMessage to an Email HOT 4
- Make S/MIME algorithms configurable (signature algorithm for signing, key encapsulation and cipher algorithms for encryption) HOT 4
- [Enhancement] Expose finer-grained DKIM configuration through the builder api and disable 'l-param' by default HOT 12
- [bug] Fix parsing addresses from headers in EML files, like a Disposition-Notification-To with umlaut HOT 1
- Update outlook-message-parser dependency, which has improved support for X500 addresses
- [Bug] Message headers not treated with case insensitivity as per RFC, causing deviating headers to slip through the filters HOT 1
- Maxing out SMTP server concurrent connections HOT 1
- outlookMsgToEmail duplicates recipients if same name used for To and Cc HOT 1
- java.lang.NoClassDefFoundError: org/jacoco/agent/rt/internal_c13123e/Offline HOT 2
- [security] Update 3rd party dependencies to get rid of all currently known CVE issues HOT 2
- [enhancement+bug] Make EmailConverter API more consistent regarding Session parameter, don't use `Session.getDefaultInstance` anymore and fix bug where `emlToEmailBuilder` used `emlToMimeMessage` HOT 3
- How to create jakarta.mail.internet.MimeMessage without accessing the mailer session? HOT 3
- Update upstream dependency generic-object-pool, which solves a critical bug when there are exceptions during allocation HOT 1
- How to esclude embedded image in email HOT 2
- When reading .msg files the RTF converted to HTML is garbled in some cases where the appropriate charset is not detected properly HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple-java-mail.