Add logging to email script