I would like to avoid spam when reading from a imap endpoint using Apache Camel.
My endpoint is configured in this way:
def camelContext = new DefaultCamelContext()
camelContext.addRoutes(new RouteBuilder() {
def void configure() {
from("imap://localhost:3143?username=myuserame&password=mypassword"
+ "&delete=false"
+ "&unseen=true"
+ "&consumer.delay=600"
+ "&fetchSize=10"
+ "&maxMessagesPerPoll=10").process{ exchange ->
...
}
I would like to add searchTerm
in order to avoid messages marked with *****SPAM****
in the subject or having the headers X-Spam-Flag: YES
or X-Spam-Status: YES
.
I would also like to blacklist some email addresses but I guess this can do this after having read the mail.
Yeah you would need to implement a custom
avax.mail.search.SearchTerm
class where you can filter the mail messages. You can find more details at: http://camel.apache.org/mail.html how to use custom search term class. Also you can check the unit test source code of camel-mail for examples.Is those spam headers a standard? I am asking as we could consider adding a check OOTB that can skip those mails if they have one of those spam headers.