Copmplete send mail function.
Move log after send success.