Added logging to email script