Skip to content
Snippets Groups Projects
Commit 76cd3d00 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

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

Rev: lib/modules/Protocols.pmod/SMTP.pmod:1.8
parent 34bb61b8
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment