Refactored the old emailer as my deadline is tonight and a full rewrite isn't practical atm