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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/SMTP.pmod:69:       if(readreturncode()/100 != 2)    throw(({"Connection refused by SMTP server.\n",backtrace()}));       if(catch(cmd("EHLO "+gethostname())))    cmd("HELO "+gethostname(), "greeting failed.");    }       void send_message(string from, string *to, string body)    { -  cmd("MAIL FROM: "+from); -  foreach(to, string t) -  cmd("RCPT TO: "+t); +  cmd("MAIL FROM: <" + from + ">"); +  foreach(to, string t) { +  cmd("RCPT TO: <" + t + ">"); +  }    cmd("DATA");    cmd(body+"\r\n.");    cmd("QUIT");    }    -  +  static string parse_addr(string addr) +  { +  array(string|int) tokens = replace(MIME.tokenize(to), '@', "@"); +  +  int i; +  tokens = tokens[search(tokens, '<') + 1..]; +  +  if ((i = search(tokens, '>')) != -1) { +  tokens = tokens[..i-1]; +  } +  return tokens*""; +  } +     void simple_mail(string to, string subject, string from, string msg)    { -  send_message(from, ({ to }), +  send_message(parse_addr(from), ({ parse_addr(to) }),    (string)MIME.Message(msg, (["mime-version":"1.0",    "subject":subject,    "from":from,    "to":to,    "content-type":    "text/plain;charset=iso-8859-1",    "content-transfer-encoding":    "8bit"])));    }   }