[Turn off line numbering]1: arg from, recip, subj, body; 2: var mailagent, header, c; 3: 4: if (!.trusts(caller()) && !.trusts(sender())) 5: throw(~perm, "Permission Denied: " + sender() + " is not trusted."); 6: mailagent = $motd.server_name() + " (" + ((| (.get_hosts_setting())[1] |) || "") + ":" + $login_daemon.current_port() + ")"; 7: (> .parse_email_address(recip) <); 8: if (!from) 9: from = 'postmaster; 10: if (type(from) == 'symbol) 11: from = .get_email_address(from); 12: header = ["Date: " + $time.format("%a, %d %b %Y %H:%M:%S %Z"), "From: " + from, "To: " + recip, "Subject: " + subj, "Errors-to: " + .get_email_address('postmaster), "X-Mail-Agent: " + mailagent]; 13: 14: // connect to maildrop 15: c = (> .connect_to_smtp_host(maildrop) <); 16: 17: // send it off 18: catch any { 19: (> .MAIL_FROM(c, from) <); 20: (> .RCPT_TO(c, recip) <); 21: (> .DATA(c, header + [""] + body) <); 22: (> .QUIT(c) <); 23: .close_session(c); 24: } with { 25: .close_session(c); 26: rethrow(error()); 27: }
// Created 13-Oct-1996 as a part of ColdCore, see: @help Credit