webmcp
changeset 5:4fb227630097 v1.0.5
Version 1.0.5
Changes in net.send_mail{...}
- Code cleanup
- A boolean success value is returned
Changes in net.send_mail{...}
- Code cleanup
- A boolean success value is returned
author | jbe |
---|---|
date | Sat Jan 02 12:00:00 2010 +0100 (2010-01-02) |
parents | 5e32ef998acf |
children | 5cba83b3f411 |
files | doc/autodoc-header.htmlpart framework/cgi-bin/webmcp.lua framework/env/net/send_mail.lua |
line diff
1.1 --- a/doc/autodoc-header.htmlpart Fri Dec 25 12:00:00 2009 +0100 1.2 +++ b/doc/autodoc-header.htmlpart Sat Jan 02 12:00:00 2010 +0100 1.3 @@ -55,10 +55,10 @@ 1.4 color: #505050; 1.5 } 1.6 </style> 1.7 - <title>WebMCP 1.0.4 Documentation</title> 1.8 + <title>WebMCP 1.0.5 Documentation</title> 1.9 </head> 1.10 <body> 1.11 - <h1>WebMCP 1.0.4 Documentation</h1> 1.12 + <h1>WebMCP 1.0.5 Documentation</h1> 1.13 <p> 1.14 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. 1.15 </p>
2.1 --- a/framework/cgi-bin/webmcp.lua Fri Dec 25 12:00:00 2009 +0100 2.2 +++ b/framework/cgi-bin/webmcp.lua Sat Jan 02 12:00:00 2010 +0100 2.3 @@ -1,6 +1,6 @@ 2.4 #!/usr/bin/env lua 2.5 2.6 -_WEBMCP_VERSION = "1.0.4" 2.7 +_WEBMCP_VERSION = "1.0.5" 2.8 2.9 -- include "../lib/" in search path for libraries 2.10 do
3.1 --- a/framework/env/net/send_mail.lua Fri Dec 25 12:00:00 2009 +0100 3.2 +++ b/framework/env/net/send_mail.lua Sat Jan 02 12:00:00 2010 +0100 3.3 @@ -1,4 +1,5 @@ 3.4 --[[-- 3.5 +success = -- true, if mail has been sent successfully, otherwise false 3.6 net.send_mail{ 3.7 envelope_from = envelope_from, -- envelope from address, not part of mail headers 3.8 from = from, -- From header address or table with 'name' and 'address' fields 3.9 @@ -25,7 +26,7 @@ 3.10 } 3.11 } 3.12 3.13 -This function sends a mail using the /usr/sbin/sendmail command. 3.14 +This function sends a mail using the /usr/sbin/sendmail command. It returns true on success, otherwise false. 3.15 3.16 --]]-- 3.17 3.18 @@ -37,21 +38,21 @@ 3.19 mail = encode.mime.mail(args) 3.20 end 3.21 local envelope_from = args.envelope_from 3.22 - local command 3.23 + local command = {"/usr/sbin/sendmail", "-t", "-i"} 3.24 if 3.25 envelope_from and 3.26 string.find(envelope_from, "^[0-9A-Za-z%.-_@0-9A-Za-z%.-_]+$") 3.27 then 3.28 - command = 3.29 - "/usr/sbin/sendmail -t -i -f " .. 3.30 - envelope_from .. 3.31 - " > /dev/null 2> /dev/null" 3.32 - else 3.33 - command = "/usr/sbin/sendmail -t -i > /dev/null 2> /dev/null" 3.34 + command[#command+1] = "-f" 3.35 + comment[#command+1] = envelope_from 3.36 + end 3.37 + local stdout, errmsg, status = os.pfilter(mail, unpack(command)) 3.38 + if not status then 3.39 + error("Error while calling sendmail: " .. errmsg) 3.40 end 3.41 - trace.debug(command) 3.42 - -- TODO: use pfilter 3.43 - local sendmail = assert(io.popen(command, "w")) 3.44 - sendmail:write(mail) 3.45 - sendmail:close() 3.46 + if status == 0 then 3.47 + return true 3.48 + else 3.49 + return false 3.50 + end 3.51 end