Refactored send_external_email! function and added tests