Two way password encryption for third party integration
===

My code needs to connect to IMAP and SMTP servers to send out and recieve emails on a periodic basis, currently every 3 mins or so. The typical user flow is as follows

1. Log in 
2. integrate your email by feeding in your IMAP and SMTP details  (including emailId and password).
3. Go to data

In the background, I run a quartz scheduler which periodically pulls emails from the IMAP server. the web UI and the quartz scheduler run in separate VM's and talk to each other on REST. 

What would be a good way to protect the user's email credentials in such a scenario? One way hashing will not help because I will never want to ask the user for his password again, but i need to provide credentials to connect on IMAP

 





