可以设置timeout属性呀!
roperty TimeOut: Integer;Description
The TimeOut property specifies the amount of time (in milliseconds) to wait for a response from the socket before an exception is raised and the current operation is aborted. If TimeOut is 0, an exception is never raised, and operations never time out.
...
NMSMTP1.Timeout := 5000; //这样如果5s内没连上的话就出异常,在OnConnectionFailed中处理
NMSMTP1.Connect;
...