How can I trigger a Java servlet function when mail is received?
-
29-09-2020 - |
Pergunta
I am aware that Google App Engine can capture email and fire a function, but I would like this functionality in a Tomcat, Glassfish, or any other Java server.
I would like to avoid setting up a mailbox and running a cron job every few seconds or minutes. A Java class and some server configuration would be ideal, but I have no idea where to start (or if I'm looking in the right direction for the solution). Maybe the solution is language-independent if the host can POST a url such as /mailHandler
when a message is received.
Any help would be greatly appreciated. Thanks! :)
Solução
I've never done this but you could maybe use Apache JAMES, run it embedded, and use the Mailet API.
Outras dicas
A Servlet engine knows nothing about mail. Your only solution is to have a mail server, of which most are scriptable and at that point do a call to your Servlet.
Check mailgun - It does have some interesting support for things like that