Fix email message sending bugs