-
Notifications
You must be signed in to change notification settings - Fork 1.1k
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
spring-integration-mail: RFC5322 conforming messages containing multiple values in from
or reply-to
headers cannot be transformed
#3560
Comments
Section 3.6.2 of RFC 5322 has been updated by RFC 6854 https://tools.ietf.org/html/rfc6854#section-2.1 but this does not change the problem described. Still |
Yes, we definitely need to follow an RFC, but it is hard to fix it without a breaking change since As a "soft" fix I suggest to convert an array of those values back to the comma-delimited single entry, so it won't be a breaking change for existing apps. In the future major version we probably can revise it in favor of handy array as it is expected by RFC. If this makes sense, I'll raise a PR with an appropriate back-port to supported versions. |
Fixes spring-projects#3560 According RFC 5322 `FROM` and `REPLY-TO` received mail message can be as an array of addresses. * Fix `MailUtils` to present those arrays as comma-delimited strings for Spring message headers * Fix tests to deal already with several addresses for `FROM` mime header. In the future we may change the logic to map those mime headers to arrays as it states according the mentioned RFC **Cherry-pick to `5.4.x` & `5.3.x`**
Fixes #3560 According RFC 5322 `FROM` and `REPLY-TO` received mail message can be as an array of addresses. * Fix `MailUtils` to present those arrays as comma-delimited strings for Spring message headers * Fix tests to deal already with several addresses for `FROM` mime header. In the future we may change the logic to map those mime headers to arrays as it states according the mentioned RFC **Cherry-pick to `5.4.x` & `5.3.x`**
Fixes #3560 According RFC 5322 `FROM` and `REPLY-TO` received mail message can be as an array of addresses. * Fix `MailUtils` to present those arrays as comma-delimited strings for Spring message headers * Fix tests to deal already with several addresses for `FROM` mime header. In the future we may change the logic to map those mime headers to arrays as it states according the mentioned RFC **Cherry-pick to `5.4.x` & `5.3.x`**
Fixes #3560 According RFC 5322 `FROM` and `REPLY-TO` received mail message can be as an array of addresses. * Fix `MailUtils` to present those arrays as comma-delimited strings for Spring message headers * Fix tests to deal already with several addresses for `FROM` mime header. In the future we may change the logic to map those mime headers to arrays as it states according the mentioned RFC **Cherry-pick to `5.4.x` & `5.3.x`**
In what version(s) of Spring Integration are you seeing this issue?
spring-integration-mail:5.4.5
Describe the bug
https://github.com/spring-projects/spring-integration/blob/main/spring-integration-mail/src/main/java/org/springframework/integration/mail/support/MailUtils.java#L52 and https://github.com/spring-projects/spring-integration/blob/main/spring-integration-mail/src/main/java/org/springframework/integration/mail/support/MailUtils.java#L56 expect a single address, and throw an exception
org.springframework.messaging.MessagingException: conversion of MailMessage headers failed; nested exception is java.lang.IllegalStateException: expected a single value but received an Array
in https://github.com/spring-projects/spring-integration/blob/main/spring-integration-mail/src/main/java/org/springframework/integration/mail/support/MailUtils.java#L69 while RFC 5322 https://tools.ietf.org/html/rfc5322#section-3.6.2 allows for a comma separated list of "mailbox specifications" (forfrom
) or "addresses" (forreply-to
). Messages that conform to RFC 5322 cannot be transformed successfully.To Reproduce
This was just a find after an analysis of production log error messages when receiving mails. It should be reproducible with mail messages containing multiple values in the
from
orreply-to
fields according to RFC 5322.Expected behavior
from
andreply-to
header fields should support multiple comma-separated addresses, be extracted successfully and copied to theAbstractIntegrationMessageBuilder
at https://github.com/spring-projects/spring-integration/blob/main/spring-integration-mail/src/main/java/org/springframework/integration/mail/transformer/AbstractMailMessageTransformer.java#L83Inbound mail messages conforming to RFC 5322 should be transformable without throwing an exception. Currently, this leads to cases where we are not able to successfully receive RFC5322 conforming inbound mail.
The text was updated successfully, but these errors were encountered: