# HG changeset patch # User jbe # Date 1262430000 -3600 # Node ID 4fb227630097d99b7d8effc99894bdcd06457103 # Parent 5e32ef998acf882301f9ff3f872b413a1b7984ee Version 1.0.5 Changes in net.send_mail{...} - Code cleanup - A boolean success value is returned diff -r 5e32ef998acf -r 4fb227630097 doc/autodoc-header.htmlpart --- a/doc/autodoc-header.htmlpart Fri Dec 25 12:00:00 2009 +0100 +++ b/doc/autodoc-header.htmlpart Sat Jan 02 12:00:00 2010 +0100 @@ -55,10 +55,10 @@ color: #505050; } - WebMCP 1.0.4 Documentation + WebMCP 1.0.5 Documentation -

WebMCP 1.0.4 Documentation

+

WebMCP 1.0.5 Documentation

WebMCP is a completely new web development framework, and has not been extensively tested yet. The API might change at any time, but in future releases there will be a list of all changes, which break downward compatibility.

diff -r 5e32ef998acf -r 4fb227630097 framework/cgi-bin/webmcp.lua --- a/framework/cgi-bin/webmcp.lua Fri Dec 25 12:00:00 2009 +0100 +++ b/framework/cgi-bin/webmcp.lua Sat Jan 02 12:00:00 2010 +0100 @@ -1,6 +1,6 @@ #!/usr/bin/env lua -_WEBMCP_VERSION = "1.0.4" +_WEBMCP_VERSION = "1.0.5" -- include "../lib/" in search path for libraries do diff -r 5e32ef998acf -r 4fb227630097 framework/env/net/send_mail.lua --- a/framework/env/net/send_mail.lua Fri Dec 25 12:00:00 2009 +0100 +++ b/framework/env/net/send_mail.lua Sat Jan 02 12:00:00 2010 +0100 @@ -1,4 +1,5 @@ --[[-- +success = -- true, if mail has been sent successfully, otherwise false net.send_mail{ envelope_from = envelope_from, -- envelope from address, not part of mail headers from = from, -- From header address or table with 'name' and 'address' fields @@ -25,7 +26,7 @@ } } -This function sends a mail using the /usr/sbin/sendmail command. +This function sends a mail using the /usr/sbin/sendmail command. It returns true on success, otherwise false. --]]-- @@ -37,21 +38,21 @@ mail = encode.mime.mail(args) end local envelope_from = args.envelope_from - local command + local command = {"/usr/sbin/sendmail", "-t", "-i"} if envelope_from and string.find(envelope_from, "^[0-9A-Za-z%.-_@0-9A-Za-z%.-_]+$") then - command = - "/usr/sbin/sendmail -t -i -f " .. - envelope_from .. - " > /dev/null 2> /dev/null" - else - command = "/usr/sbin/sendmail -t -i > /dev/null 2> /dev/null" + command[#command+1] = "-f" + comment[#command+1] = envelope_from + end + local stdout, errmsg, status = os.pfilter(mail, unpack(command)) + if not status then + error("Error while calling sendmail: " .. errmsg) end - trace.debug(command) - -- TODO: use pfilter - local sendmail = assert(io.popen(command, "w")) - sendmail:write(mail) - sendmail:close() + if status == 0 then + return true + else + return false + end end