move email generation from the model to the controller