Some bug fixes on mail sending.