Branch: Tag:

1999-06-29

1999-06-29 14:15:59 by Henrik Grubbström (Grubba) <grubba@grubba.org>

simple_mail() and send_message() are now more RFC 822 compliant.

Rev: lib/modules/Protocols.pmod/SMTP.pmod:1.8

76:       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,