# HG changeset patch # User jbe # Date 1456683363 -3600 # Node ID 5d307886bd89d18ac8f5442f34038873235602b0 # Parent 2131f02763fec93c0be8d6fd19954d9e5e16940f Added net.configure_mail{...} function to allow other mail interfaces than sendmail diff -r 2131f02763fe -r 5d307886bd89 framework/env/net/__init.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/framework/env/net/__init.lua Sun Feb 28 19:16:03 2016 +0100 @@ -0,0 +1,4 @@ +net._mail_config = { + command = { "sendmail", "-t", "-i" }, + envelope_from_option = "-f" +} diff -r 2131f02763fe -r 5d307886bd89 framework/env/net/configure_mail.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/framework/env/net/configure_mail.lua Sun Feb 28 19:16:03 2016 +0100 @@ -0,0 +1,20 @@ +--[[-- +net.configure_mail{ + command = command, -- table with binary name and static command line arguments + envelope_from_option = envelope_from_option -- command line option to select "envelope from", e.g. "-f" +} + +Configures the mail delivery system. +Default: net.configure_mail{ command={"sendmail", "-t", "-i"}, envelope_from_option="-f" } + +--]]-- + +function net.configure_mail(args) + local mail_config = { + command = table.new(args.command), + envelope_from_option = envelope_from_option + } + request.configure(function() + net._mail_config = mail_config + end) +end diff -r 2131f02763fe -r 5d307886bd89 framework/env/net/send_mail.lua --- a/framework/env/net/send_mail.lua Tue Feb 16 21:03:52 2016 +0100 +++ b/framework/env/net/send_mail.lua Sun Feb 28 19:16:03 2016 +0100 @@ -38,12 +38,13 @@ mail = encode.mime.mail(args) end local envelope_from = args.envelope_from - local command = {"/usr/sbin/sendmail", "-t", "-i"} + local command = table.new(net._mail_config.command) if envelope_from and + net._mail_config.envelope_from_option and string.find(envelope_from, "^[0-9A-Za-z%.-_@0-9A-Za-z%.-_]+$") then - command[#command+1] = "-f" + command[#command+1] = net._mail_config.envelope_from_option command[#command+1] = envelope_from end local stdout, errmsg, status = extos.pfilter(mail, table.unpack(command))