Commit 3e7a40ed authored by Ted Trask's avatar Ted Trask

Added support for envelope option for catchall accounts.

parent d5217f6b
......@@ -12,6 +12,6 @@ require("viewfunctions")
form.value.remotemailbox.readonly = true
form.value.localdomain.readonly = true
end
local order = { "remotehost", "enabled", "method", "remotemailbox", "remotepassword", "ssl", "localhost", "localmailbox", "localdomain" }
local order = { "remotehost", "enabled", "method", "remotemailbox", "remotepassword", "ssl", "localhost", "localmailbox", "localdomain", "envelope" }
displayform(form, order)
%>
......@@ -25,8 +25,8 @@ local function findkeywordsinentry(entry)
--for i,word in ipairs(entry) do reverseentry[word] = i end
-- so, have to parse word by word
-- the following is a list of the keywords we know about in this ACF
-- dns, fetchall, fetchdomains, is, local, localdomains, pass, password, proto, protocol, rewrite, smtphost, ssl, user, username
-- array of keywords that take one parameter (don't know how to handle multiple domains)
-- dns, fetchall, fetchdomains, is, local, localdomains, pass, password, proto, protocol, rewrite, smtphost, ssl, user, username, envelope
-- array of keywords that take at least one parameter (don't know how to handle multiple parameters)
local keywords = { "fetchdomains", "is", "local", "localdomains", "pass", "password", "proto", "protocol", "smtphost", "user", "username" }
local reversekeywords = {}
for i,word in ipairs(keywords) do reversekeywords[word] = i end
......@@ -188,6 +188,34 @@ local function writeentryline(entrystruct, entryline)
deleteoptionandvalue("smtpaddress")
deleteoptionandvalue("fetchdomains")
end
-- envelope is tough because it may have a no before or one or two values after
-- first, delete any envelope option (preserving the count)
local envelopecount
if reverseentry["envelope"] then
if entryline[reverseentry["envelope"]-1] == "no" then
entryline[reverseentry["envelope"]-1] = nil
else
if validator.is_integer(entryline[reverseentry["envelope"]+1] or "") then
-- Keep the number if not changing envelope option
if entryline[reverseentry["envelope"]+2] == entrystruct.value.envelope.value then
envelopecount = entryline[reverseentry["envelope"]+1]
end
entryline[reverseentry["envelope"]+2] = nil
end
entryline[reverseentry["envelope"]+1] = nil
end
entryline[reverseentry["envelope"]] = nil
end
if entrystruct.value.method.value == "pop3domain" then
if entrystruct.value.envelope.value == "disabled" then
insertentries[table.maxn(insertentries)+1] = "no"
insertentries[table.maxn(insertentries)+1] = "envelope"
else
insertentries[table.maxn(insertentries)+1] = "envelope"
insertentries[table.maxn(insertentries)+1] = envelopecount
insertentries[table.maxn(insertentries)+1] = entrystruct.value.envelope.value
end
end
if entrystruct.value.method.value == "etrn" then
deletenooption("dns")
deleteoptionandvalue("username")
......@@ -271,6 +299,7 @@ local function validateentry(entry)
end
success = modelfunctions.validateselect(entry.value.method) and success
success = modelfunctions.validateselect(entry.value.envelope) and success
if string.find(entry.value.remotehost.value, "[^%w.-]") then
entry.value.remotehost.errtxt = "Invalid entry - may only contain alphanumeric, '.', or '-'"
success = false
......@@ -469,6 +498,7 @@ function readentry(entryname, meth, remotemailbx, localdom)
local localmailbox = cfe({ label="Local Mailbox" })
local localdomain = cfe({ label="Local Domain" })
local ssl = cfe({ type="boolean", value=false, label="SSL Encryption" })
local envelope = cfe({ type="select", value="X-Envelope-To", label="Envelope Mode", option={"X-Original-To", "Delivered-To", "X-Envelope-To", "Received", "disabled"} })
local entry = findentryline(entryname, meth, remotemailbx, localdom)
if entry then
......@@ -500,9 +530,18 @@ function readentry(entryname, meth, remotemailbx, localdom)
if reverseentry["ssl"] then
ssl.value = true
end
if reverseentry["envelope"] then
if entry[reverseentry["envelope"]-1] == "no" then
envelope.value = "disabled"
elseif validator.is_integer(entry[reverseentry["envelope"]+1] or "") then
envelope.value = entry[reverseentry["envelope"]+2]
else
envelope.value = entry[reverseentry["envelope"]+1]
end
end
end
return cfe({ type="group", value={enabled=enabled, method=method, remotehost=remotehost, remotemailbox=remotemailbox, remotepassword=remotepassword, localhost=localhost, localmailbox=localmailbox, localdomain=localdomain, ssl=ssl}, label="Fetchmail Entry" })
return cfe({ type="group", value={enabled=enabled, method=method, remotehost=remotehost, remotemailbox=remotemailbox, remotepassword=remotepassword, localhost=localhost, localmailbox=localmailbox, localdomain=localdomain, ssl=ssl, envelope=envelope}, label="Fetchmail Entry" })
end
function updateentry(entrystruct)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment