refactored send email method.