File: cgiemail.pod

package info (click to toggle)
cgiemail 1.6-31
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 320 kB
  • ctags: 114
  • sloc: ansic: 1,520; makefile: 135; sh: 34
file content (417 lines) | stat: -rw-r--r-- 12,600 bytes parent folder | download | duplicates (5)
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
Be sure to read /usr/share/doc/cgiemail/README.Debian!

Here is a dump of documenation on how to use it as of October 1997.
The up-to-date version is:
	http://web.mit.edu/wwwdev/cgiemail/user.html

This is the README file, trivially edited.

=head1 NAME

cgiemail, cgiecho, cgifile - CGI Form-to-Mail conversion tools

=head1 The cgiemail user guide
                                       
This guide will help you write a WWW form that sends an e-mail message
to you. The following steps are required:

=over 4

=item

Create an e-mail template.

=item 

Put a link to the template on your page.

=item 

Decide if a mailto: link will do.

=item 

Create the HTML form.

=item 

Create more advanced HTML forms.

=item 

Make sure the ACTION is correct.

=item 

Try out your form with cgiecho.

=item 

Go live with cgiemail.

=item 

Debug if you don't get mail

=back

The following steps are optional.

=over 4

=item 

Add text to the success page.

=item 

Use an alternate success page.

=item 

Make some inputs required.

=item 

Specify formatting for some inputs.

=item 

Use CGI environment variables.

=back

=head2 Create an e-mail template.

Before you start receiving e-mail messages through the web, you should
decide what these messages should look like. Create an ASCII file,
called an e-mail template, that looks something like this:
   
    To: strangeman@chasm.big                          HEADER LINES
    Subject: questions three
                                                      blank line
    What is your name?              [yourname]
    What is your quest?             [quest]           BODY
    What is your favourite colour?  [colour]

In one sense, this template is free-form. People who want to send you
e-mail can download this template, fill it out, and mail it to you.
However, the template will also be used by the cgiemail program, so
before you upload the file to your WWW server, be careful to follow
these guidelines:

=over 4

=item

Wherever you want the user of your form to supply information, use
a single word inside square brackets with no spaces, e.g. Your
name: [yourname]. Not [Put your name here].

=item

Make sure the address in the To: field is correct.

=item

If there are blank lines among the header lines, remove them.

=item 

If there are blank lines before the header lines, remove them.

=item 

Make sure all your header lines are valid. The first character on
the line must be a letter. Most information should go in the
message body; don't make up your own headers.

=item 

Make sure there is a blank line between the header lines and the body.

=item 

Make sure you save it as ASCII text. For example, if you are using
Microsoft Word, use "Save As" and choose "Text Only with Line Breaks."

=item 

If you created the file on a Mac, be sure to upload it as text, i.e. CR's
translated. (Unix computers have different codes denoting the end of a line
than Mac's do, so your file might look like one long line to the Unix
computer.) 

=back


Within these guidelines there is a lot of flexibility. You can put
Bcc:, X-Face:, or any other header in the headers. You can put things
like Cc: [yourname] in the headers. Be creative. Just don't put
anything in there you wouldn't want your webmaster to see, because
that's where bounced messages go.
   
Now go ahead and upload your e-mail template to the WWW server and
look at it with your WWW browser.

=head2 Put a link to the template on your page.

Here's an example:

Would you like to cross the bridge? Download my "questions
three" form and send it to <strangeman@chasm.big>.

Even after you create your WWW form, you will want to leave this link
in to increase accessibility to users with disabilities.

=head2 Decide if a mailto: link will do.

Already, without any complicated HTML, you have a way for people on
the WWW to send you the information you want. Before you go to the
effort of making an HTML form, decide if it's really worth it. Forms
on the WWW have two particular disadvantages:

=over 4

=item

You will get a lot of frivolous e-mail from people who are merely
``surfing the web.''

=item

The user's e-mail address is typed manually, and is often
mistyped, so that you have no way to reply. This is less of a
problem with mailto: links.

=back

=head2 Create the HTML form.

If you've decided to create an HTML form, you need to give people a
way to supply an e-mail address. With the mailto: link, their mailer
would supply the From: address for them. But now you need to add a
line to the top of your e-mail template like this:

    From: [email]
     
Here is an example HTML form.
   
    Your e-mail address: ____________________
     
    Your name: ____________________

    Your quest: ____________________
     
    Your favourite colour: ____________________
     
    Send e-mail (This example doesn't actually send e-mail.)

This is the HTML source:
   
    <FORM METHOD="POST"
     ACTION="http://web.mit.edu/bin/cgiecho/wwwdev/cgiemail/questions3.txt">

    Your e-mail address: <INPUT NAME="email"><p>
    Your name: <INPUT NAME="yourname"><p>
    Your quest: <INPUT NAME="quest"><p>
    Your favourite colour: <INPUT NAME="colour"><p>
    <INPUT TYPE="submit" value="Send e-mail">
    </FORM>

This is a very simple example. Note that the NAME of each input
corresponds to what you previously put in the e-mail template. In this
example they are email, yourname, quest, and colour. This is the key
concept in using cgiemail. Be careful to make them exactly the same;
if you put NAME="colour" in your HTML form and [color] (note the
spelling difference) in your e-mail template, the input will not show
up in the e-mail.

=head2 Create more advanced HTML forms.

To learn to create more complicated forms, read NCSA's guide. All
of their example forms can be converted to cgiemail forms merely by
changing the ACTION. Unlike other forms-to-email programs, you are not
required to use hidden inputs with special names.

All types of inputs (radio buttons, etc.) work the same way. Each
input needs a NAME, and that name must appear within square brackets
in your e-mail template. It's that simple. To get more ideas, see
the cgiemail example page.

=head2 Make sure the ACTION is correct.

The trickiest part of the HTML form is getting the ACTION set
correctly. Start with the URL of your e-mail template, then split it
into two parts, e.g.

    http://web.mit.edu/wwwdev/cgiemail/questions3.txt
    \                /\                             /
     `--- Part 1 ---'  ` -------- Part 2 ----------'

Then you put the script name in the middle. Usually this is
``/cgi-bin/cgiecho'', but it depends on how your server is configured.
On web.mit.edu it happens to be ``/bin/cgiecho'', thus my ACTION looks
like this:

    http://web.mit.edu/bin/cgiecho/wwwdev/cgiemail/questions3.txt
    \                /\          /\                             /
     `--- Part 1 ---'  script name ` -------- Part 2 ----------'

For simplicity, you may leave out part 1, but you must include it if
you want to test your form as a local file. If you don't know what
that means, just feel free to omit part 1.

=head2 Try out your form with cgiecho.

Pop your form into your favorite WWW browser, fill in the inputs, and
submit it. You should see what the processed form looks like. If
instead you see an error with a number near 500, your ACTION is
probably set wrong. Go back to the previous step.

If some of your inputs don't seem to be showing up in the processed
form, make sure that the inputs have the exact same names in the HTML
form as in the ASCII template. E.g. NAME="yourname" in the HTML form
and [yourname] in the e-mail template.

=head2 Go live with cgiemail.

Now change cgiecho to cgiemail in the ACTION of your HTML form. Try it
out. You should receive an e-mail message with the processed form. If
you get a success page but don't receive mail, there is some problem
with your template file. Go back and make sure you correctly followed
the guidelines in step 1.

If it works, congratulations!

9. Debug if you don't get mail

Normally, mail gets sent asynchronously, meaning it goes into a queue
to be sent at at a convenient time. Asynchronous mail is sent more
efficiently and reliably, but has the disadvantage that problems can
only be reported by mailing an error message back to the sender. To
the mail system, it appears that the sender of the mail is the web
server, so the error message won't get to you.

If you aren't getting mail, you can temporarily use synchronous mail
delivery by creating a hidden input named cgiemail-mailopt and giving
it a value containing "sync", e.g.

    <INPUT TYPE="hidden" NAME="cgiemail-mailopt" VALUE="sync">

Note: For release 1.1, this won't work. Ask your webmaster to install
a newer release. Some mailers have a nonstandard extension that sends
bounces to an address in an Errors-To: header in addition to the web
server. However, some errors make this header line unreadable, so
there's no way to make absolutely sure the bounce will go to you.

=head2 Optional: Add text to the success page.

When mail is sent, a page titled ``Success'' appears with the text of
the e-mail message. You may use a hidden variable called ``addendum''
to add your own text. Here is a simple example:

    <INPUT TYPE="hidden" NAME="addendum" VALUE="Thank you!">

If you are willing to assume that readers of your form are using
recent browser software like Lynx 2.6 or Netscape 3.0, then you
may put HTML markup into this variable using the appropriate
character entities. For example, if you wanted to add

    Thank you!
     
then the HTML markup would be
   
    <em>Thank you!</em>
     
meaning you would need the following in your form:
   
    <INPUT TYPE="hidden" NAME="addendum"
     VALUE="&lt;em&gt;Thank you!&lt;/em&gt;">

Note that besides being difficult to write, this feature won't work
for people using older browser software.
   
=head2 Optional: Use an alternate success page.

If you don't like the default page that comes up when email is
successfully sent, you can specify an alternate URL using a hidden
variable called ``success'' in your HTML form, e.g.

    <INPUT TYPE="hidden" NAME="success" VALUE="http://web.mit.edu/">

Note: Start your URL with / or with http://. Otherwise cgiemail will
direct your browser to a second invocation of cgiemail, resulting in
the error No variable substitutions.

As of release 1.3, there is no way to make this alternate success page
contain information the user submitted in the form. This feature is
likely to be added in a future release.

=head2 Optional: Make some inputs required.

If you would like to automatically reject forms with certain inputs
left blank, add the prefix ``required-'' to the name of the input in
both your HTML form and your e-mail template. Here is an example:

In the HTML form:

    Your name: <INPUT NAME="required-yourname">

In the e-mail template
   
    Your name:      [required-yourname]

=head2 Optional: Specify formatting for some inputs.

If, in your e-mail template, the text inside square brackets begins
with %, cgiemail will use the printf() function in C on the field name
after the comma. If you're not familiar with this function, look in a
book on C. If you are familiar with it, please note these two
differences:

=over 4

=item

The first character in the format string must be %.

=item

Characters like \n and \t must be literal. If you want a newline, you have to
put a newline just before the comma, even though this looks strange. For
example, if Godzilla's Pizza wanted toppings listed one per line, they would
put the following in their e-mail template:

     [%s
    ,topping]
       
=back

=head2 Optional: Use CGI environment variables.

This feature may or may not work, depending on whether or not your
webmaster enabled it when configuring cgiemail.

In addition to form inputs, your e-mail template can include CGI
environment variables simply by preceding the variable's name with a
dollar sign. For example,

    [$HTTP_USER_AGENT]

will put the name of the user's browser and/or gateway in your e-mail
message. In order to be respectful of privacy, your HTML form should
warn users about any information about them that will be included in
the e-mail, e.g. HTTP_USER_AGENT, REMOTE_ADDR.

=head2 Administrivia

Upstream contact: cgiemail <cgiemail@mit.edu>

Debian maintainer: Anibal Monsalve Salazar <A.Monsalve.Salazar@IEEE.org>

Complete information on building, installing and using cgiemail is
available on the WWW:

    http://web.mit.edu/wwwdev/cgiemail/