If the SMTP server does not support the EHLO command then fallback to HELO if the server sends a "command not recognized" (error code 500) response. In other words, never use HELO unless EHLO is not supported.