Moved email functionality from controller to service