I am working on a solution in java where I need to read new messages from different email accounts (accounts with different email providers).
The current approach that I follow is by running a cron job to open these email accounts and run a loop on the inbox to get the new emails into my system.
Is there a best practice solution available for this kind of scenario?
It is more elegant to to make the code handle only one mailbox, and make the configurations come from properties file.
-Create a properties file for each mailbox with all the configurations (protocol / server / account / password etc)
-Create a cron for each mailbox with his properties file in the classpath.
This way, it is much easier to maintain:
-you have easy way to remove or add new mailboxes without rewrite code,
-easy to handle issues- seperete log file for each mailbox,
-everything is more simple (no need to think about multithreading)