webmcp
changeset 444:5d307886bd89
Added net.configure_mail{...} function to allow other mail interfaces than sendmail
author | jbe |
---|---|
date | Sun Feb 28 19:16:03 2016 +0100 (2016-02-28) |
parents | 2131f02763fe |
children | 8145293e3f4a |
files | framework/env/net/__init.lua framework/env/net/configure_mail.lua framework/env/net/send_mail.lua |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/framework/env/net/__init.lua Sun Feb 28 19:16:03 2016 +0100 1.3 @@ -0,0 +1,4 @@ 1.4 +net._mail_config = { 1.5 + command = { "sendmail", "-t", "-i" }, 1.6 + envelope_from_option = "-f" 1.7 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/framework/env/net/configure_mail.lua Sun Feb 28 19:16:03 2016 +0100 2.3 @@ -0,0 +1,20 @@ 2.4 +--[[-- 2.5 +net.configure_mail{ 2.6 + command = command, -- table with binary name and static command line arguments 2.7 + envelope_from_option = envelope_from_option -- command line option to select "envelope from", e.g. "-f" 2.8 +} 2.9 + 2.10 +Configures the mail delivery system. 2.11 +Default: net.configure_mail{ command={"sendmail", "-t", "-i"}, envelope_from_option="-f" } 2.12 + 2.13 +--]]-- 2.14 + 2.15 +function net.configure_mail(args) 2.16 + local mail_config = { 2.17 + command = table.new(args.command), 2.18 + envelope_from_option = envelope_from_option 2.19 + } 2.20 + request.configure(function() 2.21 + net._mail_config = mail_config 2.22 + end) 2.23 +end
3.1 --- a/framework/env/net/send_mail.lua Tue Feb 16 21:03:52 2016 +0100 3.2 +++ b/framework/env/net/send_mail.lua Sun Feb 28 19:16:03 2016 +0100 3.3 @@ -38,12 +38,13 @@ 3.4 mail = encode.mime.mail(args) 3.5 end 3.6 local envelope_from = args.envelope_from 3.7 - local command = {"/usr/sbin/sendmail", "-t", "-i"} 3.8 + local command = table.new(net._mail_config.command) 3.9 if 3.10 envelope_from and 3.11 + net._mail_config.envelope_from_option and 3.12 string.find(envelope_from, "^[0-9A-Za-z%.-_@0-9A-Za-z%.-_]+$") 3.13 then 3.14 - command[#command+1] = "-f" 3.15 + command[#command+1] = net._mail_config.envelope_from_option 3.16 command[#command+1] = envelope_from 3.17 end 3.18 local stdout, errmsg, status = extos.pfilter(mail, table.unpack(command))