Implement email queuing for sending/receiving

Build a more robust system for queuing emails so retries are possible and then update all send mail functions.