spring-projects / spring-integration

Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)
http://projects.spring.io/spring-integration/
Apache License 2.0
1.54k stars 1.1k forks source link

Provide a way to filter MAIL messages based on some criteria (e.g., subject contains 'FOO' etc.) and only mark them as 'read' while keeping the other messages as 'un-read'. [INT-1804] #5791

Closed spring-operator closed 10 years ago

spring-operator commented 13 years ago

Iain Porter opened INT-1804 and commented


Affects: 2.0.3

Reference URL: http://forum.springsource.org/showthread.php?p=348274&posted=1#post348274

Issue Links:

spring-operator commented 13 years ago

Neale Upstone commented

This probably applies to me too, as I've got the potential for spam, although in that requirement, a filter later on will be sufficient as I don't care about marking read.

Iain, what level of sophistication are you looking for? e.g. might you want to reference a service to lookup valid keywords in the subject?

Your request sounds like a multi-user mailbox where different users will read messages, and leave others unread.

One approach for the mark-read requirement would be to allow a SpEL expression to execute against the message to determine if the message should be marked read or not. Do you also want this expression to act as a filter as to whether the message left as unread are placed on the channel? (it sounds like you do)

In my case of using IMAP, I can see more complex scenarios of wanting to file messages into folders based on whether they were processed successfully or not. This gets us into IMAP being a potential outbound endpoint ;)

spring-operator commented 13 years ago

Iain Porter commented

My requirement is based on using the mailbox like a JMS queue. I only want to take messages off the "Inbox/unread" queue that meet my criteria. It would be like subscribing to messages from a certain sender or subject. The main point is that I want to leave messages that I don't subscribe to unread.

spring-operator commented 13 years ago

Oleg Zhurakousky commented

Implemented as per example below:

<int-mail:imap-idle-channel-adapter id="customAdapter"
    store-uri="imaps://springintegration.eip:${password}@imap.gmail.com/INBOX"
            . . . .
    java-mail-properties="javaMailProperties"
    mail-filter-expression="subject matches '(?i).*foo.*'"/>

In the above the email messages will be sent through a fine grained filtering logic provided by the SpEL expression (uses built-in Regex support) defined by 'mail-filter-expression' attribute and only the messages that contain 'foo' in the Subject will be processed. The result of the SpEL expression must be boolean. Messages that did not pass the filtering criteria will not be flagged as SEEN. Also, they will not be retrieved again by this adapter based on work done by #5812

spring-operator commented 13 years ago

Oleg Zhurakousky commented

Need to make a small change in favor of already existing Regex support in SpEL

spring-operator commented 10 years ago

Zak commented

Is there a way to filter out incoming email based on sender id in mail-filter-expression . I want to configure an inbound email adapter to be able to process emails only from ending with @something.org and filter out the rest

spring-operator commented 10 years ago

Artem Bilan commented

Zak, would be better, if you ask such a question on the http://stackoverflow.com with spring-integration tag. JIRA isn't for making help to community.

Thank you!