-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Message-Id header #563
Comments
Spring does this before sending. Maybe try that. https://github.com/spring-projects/spring-framework/blob/main/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java#L458-L463 |
Hmm, could you elaborate? Do you mean that I should do this before calling Greenmails I think it's currently out of my control. I think it's somewhere around here: I can't say exactly where. But the |
Digging a bit deeper, it's actually here: The I think Greenmail would need similar code as Spring has in your link, @apinske. Would you agree? I can't see another easy workaround either. :/ |
Can you try doing the spring-workaround before calling greenmail. Does that help? Maybe we should have the code in greenmail, I'll need to analyse that. |
Yeah, I've been trying to do that, no success. I've also tried to create my own custom extension of StoredMessage(MimeMessage mimeMessage,
Date receivedDate, long uid) {
this.receivedDate = receivedDate;
this.uid = uid;
try {
+ String messageId = this.mimeMessage.getMessageID();
this.mimeMessage = new UidAwareMimeMessage(mimeMessage, uid, receivedDate);
+ if (messageId != null) {
+ this.mimeMessage.setHeader(HEADER_MESSAGE_ID, messageId);
+ }
this.attributes = new SimpleMessageAttributes(mimeMessage, receivedDate);
} catch (MessagingException e) {
throw new IllegalStateException("Could not parse mime message " + mimeMessage + " with uid " + uid, e);
}
} |
That would probably work. But you should be able to accomplish the same in the meantime by doing the "spring-dance" (saveChanges, setHeader). The subsequent saveChanges during writeTo should not update the Message-ID again. |
That's the problem. Since Greenmail is wrapping the /**
* Update the Message-ID header. This method is called
* by the <code>updateHeaders</code> and allows a subclass
* to override only the algorithm for choosing a Message-ID.
*
* @exception MessagingException for failures
* @since JavaMail 1.4
*/
protected void updateMessageID() throws MessagingException {
setHeader("Message-ID",
"<" + UniqueValue.getUniqueMessageIDValue(session) + ">");
} I'm finding no ways around this. :/ |
Hi! I want to use a custom Message-Id when I send mails with greenmail. This makes it easier to unit test my flows. Whenever I set a Message-Id, it seems to get overwritten with something else when I run the
deliver
method. Some time stamp and my computers host name. Any ideas?I use
1.6.8
(also tried1.6.14
).The text was updated successfully, but these errors were encountered: