.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CGI::Application::Mailform 3pm" .TH CGI::Application::Mailform 3pm "2018-03-19" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CGI::Application::Mailform \- A simple HTML form to email system .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& ## In "mailform.cgi" \-\- \& use CGI::Application::Mailform; \& \& # Create a new Mailform instance... \& my $mf = CGI::Application::Mailform\->new(); \& \& # Configure your mailform \& $mf\->param(\*(AqMAIL_FROM\*(Aq => \*(Aqwebmaster@your.domain\*(Aq); \& $mf\->param(\*(AqMAIL_TO\*(Aq => \*(Aqform_recipient@your.domain\*(Aq); \& $mf\->param(\*(AqHTMLFORM_REDIRECT_URL\*(Aq => \*(Aq/uri/or/url/to/mailform.html\*(Aq); \& $mf\->param(\*(AqSUCCESS_REDIRECT_URL\*(Aq => \*(Aq/uri/or/url/to/thankyou.html\*(Aq); \& $mf\->param(\*(AqFORM_FIELDS\*(Aq => [qw/name address comments etc/]); \& \& # Optional variables \& $mf\->param(\*(AqSMTP_HOST\*(Aq => \*(Aqmail.your.domain\*(Aq); \& $mf\->param(\*(AqSUBJECT\*(Aq => \*(AqNew form submission\*(Aq); \& $mf\->param(\*(AqENV_FIELDS\*(Aq => [qw/REMOTE_ADDR HTTP_USER_AGENT/]); \& \& # Now run... \& $mf\->run(); \& exit(0); \& \& \& \& ## In "mailform.html" \-\- \&
\& \& \& \&
\& \& \& \& ## In "thankyou.html" \-\- \& \&

Thanks for your submission! It has been sent.

\& .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" CGI::Application::Mailform is a reusable and customizable mailform for the web. It is intentionally simple, and provides very few facilities. What it does do is provide an easy-to-use, secure system for taking the contents of a \s-1HTML\s0 form submission and sending it, via email, to a specified recipient. .PP This module was created as an example of how to use CGI::Application, a framework for creating reusable web-based applications. In addition to providing a simple example of CGI::Application's usage, CGI::Application::Mailform is also a fully functional application, capable of running in a production environment. .PP Just as is the case with any web-application built upon CGI::Application, CGI::Application::Mailform will run on any web server and operating system which supports the Common Gateway Interface (\s-1CGI\s0). It will run equally well on Apache as it runs on \s-1IIS\s0 or the iPlanet server. It will run perfectly well on \s-1UNIX,\s0 Linux, Solaris or Windows \s-1NT.\s0 It will take full advantage of the advanced capabilities of \s-1MOD_PERL.\s0 It will probably even run under FastCGI (although the author has not personally tested it in that environment). .SS "\s-1USAGE\s0" .IX Subsection "USAGE" Once CGI::Application::Mailform has been installed, you must complete the following steps to create a custom mailform on your website: .PP .Vb 3 \& 1. Create \*(Aqmailform.html\*(Aq \& 2. Create \*(Aqthankyou.html\*(Aq \& 3. Create \*(Aqmailform.cgi\*(Aq .Ve .PP Examples of these files are provided in the directory \*(L"Examples\*(R" which can be found in the installation tar file for CGI::Application. .SS "Create 'mailform.html'" .IX Subsection "Create 'mailform.html'" The file 'mailform.html' is simply an \s-1HTML\s0 file which contains your web form. This is the form whose contents will be sent, via CGI::Application::Mailform, to the specified recipient's email address. .PP This file need only contain the basic \s-1HTML\s0 form. There are two requirements for this form. First, the \*(L"action\*(R" attribute of the
element must refer to the \&\s-1CGI\s0 instance script ('mailform.cgi') you are about to create. Second, the form must set a \*(L"hidden\*(R" form field with the name \*(L"rm\*(R" and the value \*(L"submitform\*(R". This hidden parameter is what tells the CGI::Application::Mailform application to send the email message, as opposed to send the user to the \s-1HTML\s0 form. .PP For example: .PP .Vb 4 \& \& \& \&
.Ve .PP Your 'mailform.html' may also contain JavaScript to provide form validation. The CGI::Application::Mailform does not (currently) have any internal form validation capabilities. As described earlier, this is a very simple system. If it is necessary to enforce any fields as \*(L"required\*(R", it is recommended that JavaScript be used. .PP \&\s-1NOTE:\s0 It is not necessary that your \s-1HTML\s0 file be called 'mailform.html'. You may name this file anything you like. The only naming limitation is that the name of this file should be correctly referenced in your 'mailform.cgi', in the variable '\s-1HTMLFORM_REDIRECT_URL\s0'. .SS "Create 'thankyou.html'" .IX Subsection "Create 'thankyou.html'" The next file you need to create is your 'thankyou.html' file. This file is the simplest of all. This is the file to which users will be redirected once they have successfully submitted their form data. The purpose of this screen is to inform and assure the user that their form data submission has been successfully received and processed. .PP For example: .PP .Vb 10 \& \& \& Thank you! \& \& \&

Thanks for your submission!

\&

We have received your form, and \& we will get back to you shortly.

\& \& .Ve .PP \&\s-1NOTE:\s0 It is not necessary that your \s-1HTML\s0 file be called 'thankyou.html'. You may name this file anything you like. The only naming limitation is that the name of this file should be correctly referenced in your 'mailform.cgi', in the variable '\s-1SUCCESS_REDIRECT_URL\s0'. .SS "Create 'mailform.cgi'" .IX Subsection "Create 'mailform.cgi'" The file 'mailform.cgi' is where all the functionality of CGI::Application::Mailform is configured. This file is referred to as a \*(L"\s-1CGI\s0 instance script\*(R" because it creates an \*(L"instance\*(R" of your form. A single website may have as many instance scripts as needed. All of these instance scripts may use CGI::Application::Mailform. They may each use a different form (with different fields, etc.) if desired. The ability to create multiple instances of a single application, each with a different configuration is one of the benefits of building web-based applications using the CGI::Application framework. .PP Your instance script, 'mailform.cgi', must be created in such a way that it is treated by your web server as an executable \s-1CGI\s0 application (as opposed to a document). Generally (on \s-1UNIX\s0), this entails setting the \*(L"execute bit\*(R" on the file and configuring your web server to treat files ending \*(L".cgi\*(R" as \s-1CGI\s0 applications. Please refer to your particular web server's manual for configuration details. .PP Your instance script 'mailform.cgi' must start with the following: .PP .Vb 3 \& #!/usr/bin/perl \-w \& use CGI::Application::Mailform; \& my $mf = CGI::Application::Mailform\->new(); .Ve .PP These lines invoke the Perl interpreter, include the CGI::Application::Mailform module, and instantiate a Mailform object, respectively. (The author assumes your Perl binary is located at \*(L"/usr/bin/perl\*(R". If it is not, change the first line to refer to the correct location of your Perl binary.) .PP Once you have a Mailform object ($mf), you have to configure the Mailform for your particular application. This is done by using the \fIparam()\fR method to set a number of variables. These variables are specified as follows. .PP \&\fB\s-1REQUIRED VARIABLES\s0\fR .IP "\s-1MAIL_FROM\s0" 4 .IX Item "MAIL_FROM" .Vb 1 \& $mf\->param(\*(AqMAIL_FROM\*(Aq => \*(Aqwebmaster@your.domain\*(Aq); .Ve .Sp This variable specifies the email address from which the email created by this mailform will appear to be sent. This can be any address you like. Typically, this will be \*(L"webmaster@your.domain\*(R". Keep in mind, this is the address to which a bounce or a reply will be sent if one is generated as a result of the mailform email. The \s-1MAIL_FROM\s0 can also be useful for assisting the recipient of these email messages in automatically filtering and organizing the submissions they receive. .Sp This variable is required. If not specified, CGI::Application::Mailform will \fIdie()\fR with appropriate errors. .IP "\s-1MAIL_TO\s0" 4 .IX Item "MAIL_TO" .Vb 1 \& $mf\->param(\*(AqMAIL_TO\*(Aq => \*(Aqform_recipient@your.domain\*(Aq); .Ve .Sp This variable specifies the email address to which the email created by this mailform should be sent. This should be the email address of the person to whom the form contents should be emailed. This person will receive a reasonably formatted message every time this mailform is submitted. .Sp This variable is required. If not specified, CGI::Application::Mailform will \fIdie()\fR with appropriate errors. .IP "\s-1HTMLFORM_REDIRECT_URL\s0" 4 .IX Item "HTMLFORM_REDIRECT_URL" .Vb 1 \& $mf\->param(\*(AqHTMLFORM_REDIRECT_URL\*(Aq => \*(Aq/uri/or/url/to/mailform.html\*(Aq); .Ve .Sp This variable specifies the \s-1URL\s0 (or \s-1URI\s0) to which the web user should be redirected before they have submitted the mailform. This should be the \&\s-1HTML\s0 form which the user fills out, the contents of which will be emailed once they are submitted. .Sp This variable is required. If not specified, CGI::Application::Mailform will \fIdie()\fR with appropriate errors. .IP "\s-1SUCCESS_REDIRECT_URL\s0" 4 .IX Item "SUCCESS_REDIRECT_URL" .Vb 1 \& $mf\->param(\*(AqSUCCESS_REDIRECT_URL\*(Aq => \*(Aq/uri/or/url/to/thankyou.html\*(Aq); .Ve .Sp This variable specifies the \s-1URL\s0 (or \s-1URI\s0) to which the web user should be redirected once they have submitted the mailform. Typically, this would be a \*(L"thank you\*(R" screen which assures the user that their form submission has been received and processed. .Sp This variable is required. If not specified, CGI::Application::Mailform will \fIdie()\fR with appropriate errors. .IP "\s-1FORM_FIELDS\s0" 4 .IX Item "FORM_FIELDS" .Vb 1 \& $mf\->param(\*(AqFORM_FIELDS\*(Aq => [qw/name address comments etc/]); .Ve .Sp This variable specifies the list of \s-1HTML\s0 form fields which will be processed and sent via email to the specified recipient. Only the form fields specified in this list will be put in the email message which is generated by this mailform and sent to the specified recipient. .Sp The value of this variable must be an array reference. This variable is required. If not specified, CGI::Application::Mailform will \fIdie()\fR with appropriate errors. .PP \&\fB\s-1OPTIONAL VARIABLES\s0\fR .IP "\s-1SMTP_HOST\s0" 4 .IX Item "SMTP_HOST" .Vb 1 \& $mf\->param(\*(AqSMTP_HOST\*(Aq => \*(Aqmail.your.domain\*(Aq); .Ve .Sp This variable specifies the Internet host name (or \s-1IP\s0 address) of the server which provides Simple Mail Transfer Protocol (\s-1SMTP\s0) services. CGI::Application::Mailform sends all mail via \s-1SMTP\s0 using Net::SMTP. .Sp If \s-1SMTP_HOST\s0 is unspecified, Net::SMTP will use the default host which was specified when Net::SMTP was installed. If CGI::Application::Mailform is unable to make an \s-1SMTP\s0 connection, or successfully send mail via the \s-1SMTP\s0 host, it will \fIdie()\fR with appropriate errors. .IP "\s-1SUBJECT\s0" 4 .IX Item "SUBJECT" .Vb 1 \& $mf\->param(\*(AqSUBJECT\*(Aq => \*(AqNew form submission\*(Aq); .Ve .Sp This variable specifies the subject line of the email message which is created by this mailform. The subject is useful to the mailform recipient in easily recognizing (and possibly filtering) form submissions. .Sp This variable is optional. If not supplied, CGI::Application::Mailform will set the subject to a reasonable default. .IP "\s-1ENV_FIELDS\s0" 4 .IX Item "ENV_FIELDS" .Vb 1 \& $mf\->param(\*(AqENV_FIELDS\*(Aq => [qw/REMOTE_ADDR HTTP_USER_AGENT/]); .Ve .Sp This variable specifies the list of \*(L"environment\*(R" variables which will be processed and sent via email to the specified recipient. Only the environment variables specified in this list will be put in the email message which is generated by this mailform and sent to the specified recipient. .Sp Any environment variable which is present in the \s-1CGI\s0 environment may be included. Typical variables might be: .Sp .Vb 10 \& AUTH_TYPE \& CONTENT_LENGTH \& CONTENT_TYPE \& GATEWAY_INTERFACE \& HTTP_ACCEPT \& HTTP_USER_AGENT \& PATH_INFO \& PATH_TRANSLATED \& QUERY_STRING \& REMOTE_ADDR \& REMOTE_HOST \& REMOTE_IDENT \& REMOTE_USER \& REQUEST_METHOD \& SCRIPT_NAME \& SERVER_NAME \& SERVER_PORT \& SERVER_PROTOCOL \& SERVER_SOFTWARE .Ve .Sp See your web server documentation for a complete list and descriptions of the available environment variables. The list of environment variables specified by the \s-1CGI\s0 protocol can be found at the following \s-1URL:\s0 .Sp .Vb 1 \& http://hoohoo.ncsa.uiuc.edu/cgi/env.html .Ve .Sp The value of this variable must be an array reference. This variable is optional. If not specified, no environment variables will be included in the mailform email message. .PP Finally, you must actually cause your Mailform to be executed by calling the \fIrun()\fR method. Your instance script 'mailform.cgi' should end with the following lines: .PP .Vb 2 \& $mf\->run(); \& exit(0); .Ve .PP These lines cause your configured Mailform ($mf) to be executed, and for the program to cleanly exit, respectively. .PP \&\s-1NOTE:\s0 It is not necessary that your \s-1HTML\s0 file be called 'mailform.cgi'. You may name this file anything you like. The only naming limitations are that this file should be named so that your web server recognizes it as an executable \s-1CGI,\s0 and that your \&'mailform.html' file specifies your instance script in the \*(L"action\*(R" attribute of the
element. .PP All things considered, your \s-1CGI\s0 instance script will be a very small, simple file. Unlike other reusable \*(L"mailform\*(R" scripts, the instance scripts are specifically intended to be very easy to work with. Essentially, these instance scripts are \*(L"configuration files\*(R" for your web-based application. The structure of instance scripts is a benefit of building applications based on the CGI::Application framework. .SH "SEE ALSO" .IX Header "SEE ALSO" CGI::Application .SH "AUTHOR" .IX Header "AUTHOR" Jesse Erlbaum .SH "LICENSE" .IX Header "LICENSE" Copyright (c) 2001, 2002, Jesse Erlbaum . .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.