Move mail function to aop finished