You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes: #9613
Issue link: #9613
Sometimes even if `\Recent` or user flag is not supported by mail server, the `\Flagged` is also undesirable
* Expose `AbstractMailReceiver.setFlaggedAsFallback()` to disable setting `\Flagged` on the message as fallback
* As well as expose `MailInboundChannelAdapterSpec.flaggedAsFallback()`
* Document the new option
Copy file name to clipboardExpand all lines: spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/MailInboundChannelAdapterSpec.java
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -269,6 +269,19 @@ public S autoCloseFolder(boolean autoCloseFolder) {
269
269
return_this();
270
270
}
271
271
272
+
/**
273
+
* Whether the {@link jakarta.mail.Flags.Flag#FLAGGED} flag should be added to the message
274
+
* when {@code \Recent} or user flags are not supported on mail server.
275
+
* @param flaggedAsFallback {@code false} to not add {@link jakarta.mail.Flags.Flag#FLAGGED} flag as a fallback.
Copy file name to clipboardExpand all lines: src/reference/antora/modules/ROOT/pages/mail.adoc
+7-4Lines changed: 7 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -328,7 +328,7 @@ The following example configures an IMAP `idle` mail channel:
328
328
329
329
You can provide `javaMailProperties` by creating and populating a regular `java.utils.Properties` object -- for example, by using the `util` namespace provided by Spring.
330
330
331
-
IMPORTANT: If your username contains the '@' character, use '%40' instead of '@' to avoid parsing errors from the underlying JavaMail API.
331
+
IMPORTANT: If your username contains the `@` character, use `%40` instead of `@` to avoid parsing errors from the underlying JavaMail API.
332
332
333
333
The following example shows how to configure a `java.util.Properties` object:
334
334
@@ -459,8 +459,11 @@ If `shouldMarkMessagesAsRead` is true, the IMAP adapters set the `\Seen` flag.
459
459
In addition, when an email server does not support the `\Recent` flag, the IMAP adapters mark messages with a user flag (by default, `spring-integration-mail-adapter`), as long as the server supports user flags.
460
460
If not, `Flag.FLAGGED` is set to `true`.
461
461
These flags are applied regardless of the `shouldMarkMessagesRead` setting.
462
+
However, starting with version 6.4, the `\Flagged` can be disabled, too.
463
+
The `AbstractMailReceiver` exposes a `setFlaggedAsFallback(boolean flaggedAsFallback)` option to skip setting `\Flagged`.
464
+
In some scenarios such a flag on the message in mailbox is not desirable, regardless `\Recent` or user flag is not suppoerted as well.
462
465
463
-
As discussed in xref:mail.adoc#search-term[null], the default `SearchTermStrategy` ignore messages that are so flagged.
466
+
As discussed in xref:mail.adoc#search-term[`SearchTerm`], the default `SearchTermStrategy` ignore messages that are so flagged.
464
467
465
468
Starting with version 4.2.2, you can set the name of the user flag by using `setUserFlag` on the `MailReceiver`.
466
469
Doing so lets multiple receivers use a different flag (as long as the mail server supports user flags).
@@ -473,12 +476,12 @@ Very often, you may encounter a requirement to filter incoming messages (for exa
473
476
You can accomplish this by connecting an inbound mail adapter with an expression-based `Filter`.
474
477
Although it would work, there is a downside to this approach.
475
478
Since messages would be filtered after going through the inbound mail adapter, all such messages would be marked as read (`SEEN`) or unread (depending on the value of `should-mark-messages-as-read` attribute).
476
-
However, in reality, it be more useful to mark messages as `SEEN` only if they pass the filtering criteria.
479
+
However, in reality, it is more useful to mark messages as `SEEN` only if they pass the filtering criteria.
477
480
This is similar to looking at your email client while scrolling through all the messages in the preview pane, but only flagging messages that were actually opened and read as `SEEN`.
478
481
479
482
Spring Integration 2.0.4 introduced the `mail-filter-expression` attribute on `inbound-channel-adapter` and `imap-idle-channel-adapter`.
480
483
This attribute lets you provide an expression that is a combination of SpEL and a regular expression.
481
-
For example if you would like to read only emails that contain 'Spring Integration' in the subject line, you would configure the `mail-filter-expression` attribute like as follows: `mail-filter-expression="subject matches '(?i).*Spring Integration.*"`.
484
+
For example if you would like to read only emails that contain 'Spring Integration' in the subject line, you would configure the `mail-filter-expression` attribute like as follows: `mail-filter-expression="subject matches '(?i).\*Spring Integration.*"`.
482
485
483
486
Since `jakarta.mail.internet.MimeMessage` is the root context of the SpEL evaluation context, you can filter on any value available through `MimeMessage`, including the actual body of the message.
484
487
This one is particularly important, since reading the body of the message typically results in such messages being marked as `SEEN` by default.
0 commit comments