pike.git / lib / modules / Protocols.pmod / SMTP.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/SMTP.pmod:111:    //! @throws    //! If the mail server returns any other return code than    //! 200-399 an exception will be thrown.    void send_message(string from, array(string) to, string body)    {    cmd("MAIL FROM: <" + from + ">");    foreach(to, string t) {    cmd("RCPT TO: <" + t + ">");    }    cmd("DATA"); -  cmd(body+"\r\n."); +  +  // Perform quoting according to RFC 2821 4.5.2. +  if (sizeof(body) && body[0] == '.') { +  body = "." + body; +  } +  body = replace(body, "\r\n.", "\r\n.."); +  +  // RFC 2841 4.1.1.4: +  // An extra <CRLF> MUST NOT be added, as that would cause an empty +  // line to be added to the message. +  if (has_suffix(body, "\r\n")) { +  body += "."; +  } else { +  body += "\r\n."; +  } +  cmd(body);    cmd("QUIT");    }       static string parse_addr(string addr)    {    array(string|int) tokens = replace(MIME.tokenize(addr), '@', "@");       int i;    tokens = tokens[search(tokens, '<') + 1..];