summaryrefslogtreecommitdiffstats
path: root/fetchmail-config-html.lsp
blob: 7c0a0ca44460050418595b6608dbb060b95ef732 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<? local form = ... ?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
io.write(html.cfe_unpack(form))
io.write("</span>")
--]]
?>

<?
function informationform(myform,tags)
	io.write("<DL>")
	for k,v in pairs(tags) do 
		if (myform[v]) then
			local val = myform[v] 
			io.write("\t<DT")
			if (#val.errtxt > 0) then io.write(" class='error'") end
			io.write(">" .. val.label .. "</DT>\n")

			io.write("\t\t<DD>" .. val.value .. "\n")
			if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
			if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
			io.write("\t\t</DD>\n")
		end
	end
	io.write("</DL>")
end
?>
<?
function configform(myform,tags)
	io.write("<DL>")
	for k,v in pairs(tags) do 
		if (myform[v]) then
			local val = myform[v] 
			io.write("\t<DT")
			if (#val.errtxt > 0) then io.write(" class='error'") end
			io.write(">" .. val.label .. "</DT>\n")

			io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
			if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
			if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
			io.write("\t\t</DD>\n")
		end
	end
	io.write("</DL>")
end
?>

<H1>SYSTEM INFO</H1>
<? 
local myform = form.status 
local tags = { "status", "version", }
informationform(myform,tags)
?>

<H1>CONFIGURATION</H1>
<? local myform = form.config ?>
<form action="<?= form.option.script .. "/" .. form.option.prefix ..
		form.option.controller .. "/" .. form.option.action ?>" method="POST">

<H2>GUIDED CONFIGURATION</H2>
<? --[[ ?>
<H3>FREQUENCY</H3>
<P>Select how often the mailboxes will be checked. For ETRN transfers (below) this specifies how often transfers are initiated</P>
<? 
local tags = { "freq", }
configform(myform,tags)
?>
<? --]] ?>

<H3>MAILBOXES</H3>
<P>In the boxes below, select up to 10 mailboxes to check for mail. You will need to specify the remote mailbox and password, as well as the local (internal) mailbox to forward the mail to. The SMTP host is the name or address of the SMTP server to send the mail to. For mail destined for the internal branch network, this should be <B>svcoutside</B> (the address of the outside interface of the services BSN component). This is then forwarded to the to the internal component of the BSN for sending on to the branch network.</P>

<P>For branches that use a POP3 account for the entire domain, selecting the <U>pop3domain</U> method will setup the appropriate configuration for retrieving and distributing the mail appropriately. The <B>domain</B> information should be your internet smtp domain. The <B>mailbox</B> field is ignored when this method is selected.</P>

<P>When selecting the <U>pop3</U> or <U>imap</U> methods, the <B>domain</B> field should be left blank.</P>
<? -- START - SPECIAL VIEW FOR SHOWING AVAILABLE MAILBOXES ?>
<?
local tags = "mailboxes" 
local mailboxform = myform[tags]["value"]
?>
<DL>
<? 
	io.write("\n\t<CENTER><TABLE STYLE='width:90%;border:1px solid #ccc;background:#eee'>\n\t\t<TR>\n\t\t\t<TD CLASS='header' WIDTH='130px'>")
	io.write("<CENTER>METHOD</CENTER></TD>\n\t\t\t<TD CLASS='header' COLSPAN=2>")
	io.write("<CENTER>REMOTE</CENTER></TD>\n\t\t\t<TD CLASS='header' COLSPAN=2>")
	io.write("<CENTER>LOCAL</CENTER></TD>\n\t\t</TR>")
for i=1, table.maxn(mailboxform) do
		leftpadd="30px"
		rightpadd="5px"

		io.write("\n\t\t<TR>\n\t\t\t<TD>")
			val = "method"
			io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
		io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";' WIDTH='5%'>")
			val = "remotehost"
			io.write(mailboxform[i][val]["label"])
		io.write(":</TD>\n\t\t\t<TD>")
			io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
		io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";' WIDTH='5%'>")
			val = "localhost"
			io.write(mailboxform[i][val]["label"])
		io.write(":</TD>\n\t\t\t<TD>")
			io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
		io.write("</TD>\n\t\t</TR>")
		io.write("\n\t\t<TR>\n\t\t\t<TD>")
			val = "disabled"
			io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
			io.write(" " .. mailboxform[i][val]["label"])
		io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
			val = "remotemailbox"
			io.write(mailboxform[i][val]["label"])
		io.write(":</TD>\n\t\t\t<TD>")
			io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
		io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
			val = "localmailbox"
			io.write(mailboxform[i][val]["label"])
		io.write(":</TD>\n\t\t\t<TD>")
			io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
		io.write("</TD>\n\t\t</TR>")
		io.write("\n\t\t<TR>\n\t\t\t<TD>")
		io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
			val = "remotepassword"
			io.write(mailboxform[i][val]["label"])
		io.write(":</TD>\n\t\t\t<TD>")
			io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
		io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
			val = "localdomain"
			io.write(mailboxform[i][val]["label"])
		io.write(":</TD>\n\t\t\t<TD>")
			io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
		io.write("</TD>\n\t\t</TR>")
		io.write("\n\t\t<TR>\n\t\t\t<TD COLSPAN=5><HR></TD>\n\t\t</TR>")
end
io.write("</TABLE></CENTER>")
?>
<DL>
<? -- START - SPECIAL VIEW FOR SHOWING AVAILABLE MAILBOXES ?>

<H3>LAST RESORT</H3>
<P>The Postmaster address is the address of last resort when fetchmail cannot determine how to send a mail message. If left blank, undelieverable mail may be discarded.</P>
<? 
local tags = { "postmaster", }
configform(myform,tags)
?>

<H3>ETRN</H3>
<P>This is for branches that have DNS mail domains hosted by an ISP that allows for ETRN dequeueing. ETRN dequeueing causes the SMTP mail exchanger at the ISP to forward mail to you via SMTP. You will need to make sure that DNS is setup appropriately and that your ISP supports ETRN. If you have not arranged with your ISP to have ETRN support, leave these fields blank.</P>
<? 
local tags = { "etrnremote","etrnquedomain", }
configform(myform,tags)
?>


<? --[[ ?>
<H2>ADVANCED CONFIGURATION</H2>
<H3>GENERAL</H3>
<? 
local tags = { "logfile", "loglevel", "smallerlogs", }
configform(myform,tags)
?>

<? --]] ?>

<H2>SAVE AND APPLY ABOVE SETTINGS</H2>
<? 
local tags = { "cmdsave","cmdtest", }
configform(myform,tags)
?>
</form>

<? 
local cmdform = form.management
local tags = { "start", "stop", "restart" }
if (cmdform) and (cmdform[tags[1]]) then
?>
	<form name="management" action="" method="POST">
	<H1>MANAGEMENT</H1>
	<dl>
		<dt><?= cmdform[tags[1]]["label"] ?></dt>
		<dd>
		<? for k,v in pairs(tags) do ?>
			<? if (cmdform[v]) then ?>
				<? io.write(html.form[cmdform[v].type](cmdform[v])) ?>
			<? end ?>
		<? end ?>
		</dd>

		<? if (form.cmdmanagement) and (#form.cmdmanagement.descr > 0) then ?>
		<dt>Previous action result</dt>
			<dd><pre><?= form.cmdmanagement.descr ?></pre></dd>
		<? end ?>
	</dl>
	</form>

<? end ?>

<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
io.write(html.cfe_unpack(form))
io.write("</span>")
--]]
?>