Method code for $smtp.DATA()

[Turn on line numbering]
arg c, body;
var lines, code, line, i;

.set_timeout(c, 120);
c.write("DATA");
lines = (> .get_response(c) <);
[code, line] = lines[1];
if (code != 354)
    throw(~error, lines.slice(2).join(), code);

// escape period DATA termination
while ((i = find i in (body) where (i == ".")))
    body = replace(body, i, "..");

// send it
c.write(body + ["."]);
lines = (> .get_response(c) <);
[code, line] = lines[1];
if (code != 250)
    throw(~error, lines.slice(2).join(), code);

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

Tlon