Fix bug for sending emails