View/Edit #12:@@sendmail

Switch to edit mode.

Name(s): @@sendmail
1:  "Syntax: @@sendmail"
2:  "This is intended for use with client editors.  You probably don't want to try using this command manually."
3:  "Reads a formatted mail message, extracts recipients, subject line and/or reply-to header and sends message without going to the mailroom.  Example:"
4:  ""
5:  "@@send"
6:  "To: Rog (#4292)"
7:  "Subject: random"
8:  ""
9:  "first line"
10: "second line"
11: "."
12: ""
13: "Currently, header lines must have the same format as in an actual message."
14: set_task_perms(player)
15: if (args)
16:   player:notify(tostr("The ", verb, " command takes no arguments."))
17:   $command_utils:read_lines()
18:   return
19: elseif (this != player)
20:   player:notify(tostr("You can't use ", this.pp, " ", verb, " verb."))
21:   $command_utils:read_lines()
22:   return
23: endif
24: msg = $command_utils:read_lines()
25: end_head = "" in msg || length(msg) + 1
26: from = this
27: subject = ""
28: replyto = ""
29: rcpts = {}
30: body = msg[end_head + 1..length(msg)]
31: for i in [1..end_head - 1]
32:   line = msg[i]
33:   if (index(line, "Subject:") == 1)
34:     subject = $string_utils:trim(line[9..length(line)])
35:   elseif (index(line, "To:") == 1)
36:     if (!(rcpts = $mail_agent:parse_address_field(line)))
37:       player:notify("No recipients found in To: line")
38:       return
39:     endif
40:   elseif (index(line, "Reply-to:") == 1)
41:     if (!(replyto = $mail_agent:parse_address_field(line)) && $string_utils:trim(line[10..length(line)]))
42:       player:notify("No address found in Reply-to: line")
43:       return
44:     endif
45:   elseif (index(line, "From:") == 1)
46:     "... :send_message() bombs if designated sender != player ..."
47:     if (!(from = $mail_agent:parse_address_field(line)))
48:       player:notify("No sender found in From: line")
49:       return
50:     elseif (length(from) > 1)
51:       player:notify("Multiple senders?")
52:       return
53:     endif
54:     from = from[1]
55:   elseif (i = index(line, ":"))
56:     player:notify(tostr("Unknown header \"", line[1..i], "\""))
57:     return
58:   else
59:     player:notify("Blank line must separate headers from body.")
60:     return
61:   endif
62: endfor
63: if (!rcpts)
64:   player:notify("No To: line found.")
65: elseif (!(subject || body))
66:   player:notify("Blank message not sent.")
67: else
68:   player:notify("Sending...")
69:   result = $mail_agent:send_message(from, rcpts, replyto ? subject | {subject, replyto}, body)
70:   if (e = result && result[1])
71:     if (length(result) == 1)
72:       player:notify("Mail actually went to no one.")
73:     else
74:       player:notify(tostr("Mail actually went to ", $mail_agent:name_list(@listdelete(result, 1)), "."))
75:     endif
76:   else
77:     player:notify(tostr(typeof(e) == $ERR ? e | "Bogus recipients:  " + $string_utils:from_list(result[2])))
78:     player:notify("Mail not sent.")
79:   endif
80: endif
81: "Last modified by Dax (#789) on Tue May  3 13:57:40 2005 MDT."

Verb arguments: any any any
Verb perms: Readable NOT-Debug
Verb owned by: Slacker (#55)

You are not logged in.

[home | help | who | search | setup | code]