Fix some bugs to send an email.