Fix bug of sending emails