Method code for $smtp.negotiate_connect()

[Turn off line numbering]
  1: arg c;
  2: var lines, code, line;
  3: 
  4: .set_timeout(c, 120);
  5: lines = (> .get_response(c) <);
  6: [code, line] = lines[1];
  7: if (code == 421)
  8:     throw(~notavail, lines.slice(2).join());
  9: if (code != 220)
 10:     throw(~invalid, "Unknown response from server: " + code + " " + line);
 11: .set_timeout(c, 120);
 12: c.write("HELO " + $sys.server_info('server_hostname));
 13: lines = (> .get_response(c) <);
 14: [code, line] = lines[1];
 15: if (code == 250)
 16:     return;
 17: if (code % 500 < 100)
 18:     throw(~syntax, "I'm doing something wrong: " + line);
 19: if (code == 421)
 20:     throw(~notavail, lines.slice(2).join());
 21: throw(~invalid, "Unknown response from server: " + code + " " + line);

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

Tlon