webmcp
annotate framework/env/net/send_mail.lua @ 1:985024b16520
Version 1.0.1
New feature: JSON requests
Changes in ui.paginate: Current page setting is directly fetched from CGI params, instead of view params
Changed behavior of load methods of atom library to accept nil as input
Bugfixes in mondelefant_atom_connector timestamp(tz) loaders
Added global constant _WEBMCP_VERSION containing a version string
New feature: JSON requests
Changes in ui.paginate: Current page setting is directly fetched from CGI params, instead of view params
Changed behavior of load methods of atom library to accept nil as input
Bugfixes in mondelefant_atom_connector timestamp(tz) loaders
Added global constant _WEBMCP_VERSION containing a version string
author | jbe |
---|---|
date | Tue Nov 17 12:00:00 2009 +0100 (2009-11-17) |
parents | 9fdfb27f8e67 |
children | 4fb227630097 |
rev | line source |
---|---|
jbe/bsw@0 | 1 --[[-- |
jbe/bsw@0 | 2 net.send_mail{ |
jbe/bsw@0 | 3 envelope_from = envelope_from, -- envelope from address, not part of mail headers |
jbe/bsw@0 | 4 from = from, -- From header address or table with 'name' and 'address' fields |
jbe/bsw@0 | 5 sender = sender, -- Sender header address or table with 'name' and 'address' fields |
jbe/bsw@0 | 6 reply_to = reply_to, -- Reply-To header address or table with 'name' and 'address' fields |
jbe/bsw@0 | 7 to = to, -- To header address or table with 'name' and 'address' fields |
jbe/bsw@0 | 8 cc = cc, -- Cc header address or table with 'name' and 'address' fields |
jbe/bsw@0 | 9 bcc = bcc, -- Bcc header address or table with 'name' and 'address' fields |
jbe/bsw@0 | 10 subject = subject, -- subject of e-mail |
jbe/bsw@0 | 11 multipart = multipart_type, -- "alternative", "mixed", "related", or nil |
jbe/bsw@0 | 12 content_type = content_type, -- only for multipart == nil, defaults to "text/plain" |
jbe/bsw@0 | 13 binary = binary, -- allow full 8-bit content |
jbe/bsw@0 | 14 content = content or { -- content as lua-string, or table in case of multipart |
jbe/bsw@0 | 15 { |
jbe/bsw@0 | 16 multipart = multipart_type, |
jbe/bsw@0 | 17 ..., |
jbe/bsw@0 | 18 content = content or { |
jbe/bsw@0 | 19 {...}, ... |
jbe/bsw@0 | 20 } |
jbe/bsw@0 | 21 }, { |
jbe/bsw@0 | 22 ... |
jbe/bsw@0 | 23 }, |
jbe/bsw@0 | 24 ... |
jbe/bsw@0 | 25 } |
jbe/bsw@0 | 26 } |
jbe/bsw@0 | 27 |
jbe/bsw@0 | 28 This function sends a mail using the /usr/sbin/sendmail command. |
jbe/bsw@0 | 29 |
jbe/bsw@0 | 30 --]]-- |
jbe/bsw@0 | 31 |
jbe/bsw@0 | 32 function net.send_mail(args) |
jbe/bsw@0 | 33 local mail |
jbe/bsw@0 | 34 if type(args) == "string" then |
jbe/bsw@0 | 35 mail = args |
jbe/bsw@0 | 36 else |
jbe/bsw@0 | 37 mail = encode.mime.mail(args) |
jbe/bsw@0 | 38 end |
jbe/bsw@0 | 39 local envelope_from = args.envelope_from |
jbe/bsw@0 | 40 local command |
jbe/bsw@0 | 41 if |
jbe/bsw@0 | 42 envelope_from and |
jbe/bsw@0 | 43 string.find(envelope_from, "^[0-9A-Za-z%.-_@0-9A-Za-z%.-_]+$") |
jbe/bsw@0 | 44 then |
jbe/bsw@0 | 45 command = |
jbe/bsw@0 | 46 "/usr/sbin/sendmail -t -i -f " .. |
jbe/bsw@0 | 47 envelope_from .. |
jbe/bsw@0 | 48 " > /dev/null 2> /dev/null" |
jbe/bsw@0 | 49 else |
jbe/bsw@0 | 50 command = "/usr/sbin/sendmail -t -i > /dev/null 2> /dev/null" |
jbe/bsw@0 | 51 end |
jbe/bsw@0 | 52 trace.debug(command) |
jbe/bsw@0 | 53 -- TODO: use pfilter |
jbe/bsw@0 | 54 local sendmail = assert(io.popen(command, "w")) |
jbe/bsw@0 | 55 sendmail:write(mail) |
jbe/bsw@0 | 56 sendmail:close() |
jbe/bsw@0 | 57 end |