Method code for $smtp.connect_to_smtp_host()

[Turn on line numbering]
arg ip, @host;
var line, c;

if (host)
    host = host[1];
else
    host = ip;
c = $outbound_connection.new();
catch any {
    c.open_connection(ip, 25);
    (> .negotiate_connect(c) <);
} with {
    (| c.close() |);
    if (error() == ~refused)
        throw(~refused, "Unable to open SMTP connection to " + host);
    else
        rethrow(error());
}
return c;

// Created 13-Oct-1996 as a part of ColdCore, see: @help Credit

Tlon