adding email and templates functionality