From 76cd3d00abc030f9842210ccbd5b3e3e180b1f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Tue, 29 Jun 1999 16:15:59 +0200 Subject: [PATCH] simple_mail() and send_message() are now more RFC 822 compliant. Rev: lib/modules/Protocols.pmod/SMTP.pmod:1.8 --- lib/modules/Protocols.pmod/SMTP.pmod | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/modules/Protocols.pmod/SMTP.pmod b/lib/modules/Protocols.pmod/SMTP.pmod index 91f5129e55..c2324b7aa4 100644 --- a/lib/modules/Protocols.pmod/SMTP.pmod +++ b/lib/modules/Protocols.pmod/SMTP.pmod @@ -76,17 +76,31 @@ class client 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, -- GitLab