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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/SMTP.pmod:223:    int givedata = 1;   };      //! The low-level class for the SMTP server   class Connection {       inherit Configuration;    // The commands this module supports    array(string) commands = ({ "ehlo", "helo", "mail", "rcpt", "data",    "rset", "vrfy", "quit", "noop" }); -  // do we speak LMTP ? -  int lmtp_mode = 0; +  constant protocol = "ESMTP";       // the fd of the socket    static object fd = Stdio.File();    // the domains for each i relay    static array(string) mydomains = ({ });    // the input buffer for read_cb    static string inputbuffer = "";    // the size of the old data string in read_cb    static int sizeofpreviousdata = 0;    // the from address
pike.git/lib/modules/Protocols.pmod/SMTP.pmod:295:    werror(errmsg, args);    }       // make the received header    static string received()    {    string remotehost =    Protocols.DNS.client()->gethostbyaddr(remoteaddr)[0]    || remoteaddr;    string rec; -  string mode = lmtp_mode ? "LMTP": "ESMTP"; -  rec=sprintf("from %s (%s [%s]) " -  "by %s (Pike %s server) with %s id %d ; %s", +  rec=sprintf("from %s (%s [%s]) by %s (Pike "+protocol+ +  " server) with "+protocol+" id %d ; %s",    ident, remotehost, remoteaddr, -  gethostname(), mode, mode, messageid, -  Calendar.now()->format_smtp()); +  gethostname(), messageid, Calendar.now()->format_smtp());    return rec;    }       void helo(string argument)    {    remove_call_out(handle_timeout);    call_out(handle_timeout, 310, "HELO");    if(sizeof(argument) > 0)    {    fd->write("250 %s\r\n", localhost);
pike.git/lib/modules/Protocols.pmod/SMTP.pmod:518:    message->headers->received = received()    + "\0"+message->headers->received;    if(!message->headers["message-id"])    {    message->headers["message-id"] = sprintf("<%d@%s>", messageid,    gethostname());    }    return message;    }    -  void message(string content) +  MIME.Message low_message(string content)    {    datamode = 0;    if(sizeof(content) > maxsize)    {    outcode(552); -  return; +  return 0;    } -  object message; +  MIME.Message message;    mixed err = catch (message = MIME.Message(content));    if(err)    {    outcode(554);    log(describe_backtrace(err));    log("content is %O\n", content); -  return; +  return 0;    }    err = catch {    message = format_headers(message);    };    if(err)    {    outcode(554);    log(describe_backtrace(err)); -  return; +  return 0;    } -  // if we are in LMTP mode we call cb_data for each recipient -  // and with one recipient. This way we have one mime message per -  // recipient and one outcode to display to the client per recipient -  // (that is LMTP specific) -  if(lmtp_mode) -  { -  foreach(mailto, string recipient) -  { -  int check; -  if(givedata) -  err = catch(check = cb_data(copy_value(message), mailfrom, -  recipient, content)); -  else -  err = catch(check = cb_data(copy_value(message), mailfrom, recipient)); -  if(err || !check) -  { -  outcode(554); -  log(describe_backtrace(err)); -  continue; +  return message;    } -  outcode(check); -  } -  } +  +  void message(string content) { +  MIME.Message message = low_message(content); +  if(!message) return; +     // SMTP mode, cb_data is called one time with an array of recipients    // and the same MIME object -  else -  { +     int check; -  +  mixed err;    if(givedata)    err = catch(check = cb_data(message, mailfrom, mailto, content));    else    err = catch(check = cb_data(message, mailfrom, mailto));    if(err || !check)    {    outcode(554);    log(describe_backtrace(err));    return;    }    outcode(check);    } -  } +        void noop()    {    remove_call_out(handle_timeout);    call_out(handle_timeout, 310, "NOOP");    outcode(250);    }       void rset()    {