Mailform - Create E-mail input form and send E-mail to recipient

Access counter


NAME

Mailform - Create E-mail input form and send E-mail to recipient

$Id: Mailform.pm,v 1.3 2002/11/04 14:16:31 t_shigetome Exp $


SYNOPSIS

        use CGI;
        use Mailform;
        my(%config) = (
                'subject'       =>      'No subject',
                'redirect'      =>      'mailtest.txt', # It's for debug
                'sendmail'      =>      ['/usr/lib/sendmail -n -t -oi'],
                'nexturl'       =>      'index.html',
        );
        my(%recipient) = (
                'Someone'               =>      'someone@anywhere.com',
                'Anotherone'    =>      'Anotherone@anywhere.com',
                'Each'                  =>      'Someone;Anotherone',
                'All'                   =>      'Someone;Anotherone;boss@anywhere.com',
        );
        my($form) = new Mailform($ENV{'REQUEST_URI'});
        $form->ParseQuery();
        $form->SetParameter(\%config, \%recipient);
        $form->OutResponse();


DESCRIPTION

This is for CGI program. Generate E-mail send form. Posted message will be send to selected receiver. Support base64 encoding for unsafe character in subject and name. This form support only Japanese Kanji code like as Shift-JIS.

CGI ARGUMENT

config
Value of `config' in QUERY_STRING. That value is used for hint of selecting from parameter set.

nexturl
Use with location header after post form. Default value is HTTP_REFERER.

METHOD

new( $mailform_URI)
Create new instance The $mailform_URI is used at action attribute in input form.
        my($form) = new Mailform($ENV{'REQUEST_URI'});

SetParameter($filename) or SetParameter($rh_para, $rh_alias)
Setup of parameter. The $filename is filename of parameter file. That parameter file will be parsed with Params.pm.

The $rh_para and $rh_alias are hash reference of parameter. See following description for parameters. The $rh_alias is hash refrence of recipient list. If you want to assign two or more receivers to one alias, you can describe separated each one `;'.

Parameter description

subject
Specify default subject.

nexturl
Specify default next URL after post mail.

sendmail
Optional parameter. Specify sendmail command and options. For detail, see sub SendMail.

redirect
It's for debug. Do not sendmail, but save to specified file to post message with MIME header.

recipient
Specify E-mail recipient as alias. It can be nested by alias name.

Refer following sample source to use parameter file.

sample.cgi

        use CGI;
        use Mailform;
        my($form) = new Mailform($ENV{'REQUEST_URI'});
        $form->ParseQuery();
        $main::configname = $form->config();
        $form->SetParameter("sample.par");
        $form->OutResponse();

sample.par

        #if $main::configname eq 'test'
        #       define CONFIG   test
        #endif
        %CONFIG% redirect{
                testmail.txt;
        };
        %CONFIG% subject{
                default subject
        };
        %CONFIG%        nexturl{
                /~yahoo/index.html;
        };
        recipient foo{
                foo@anywhere.com;
        };
        recipient ya{
                ya@anytime.com;
        };
        recipient all{
                ya;
                foo;
        };
ParseQuery()
Parse query string or post data.

OutResponse()
Output result. If it send mail, it will be return location header and move to next URL.

SetTemplate($templatefile)
The $templatefile is template file name. It is used as template of mailform page. You can customize that. But it's not simple. That template file is expanded with replace keys. For detail, see default template data in sub GetTemplate. See also InputFormTemplateFile

InputFormTemplateFile($filename)
The $filename is template file name. It is used as input form template. You can customize that. That template file is expanded at replace keys. For detail, see default template data in sub GetFormTemplate.

debug($debug_opt)
Toggle each debug condition. Default is debug off. There are five debugging options.
        $form->debug('configpara');
        $form->debug('query_string');
        $form->debug('alias');
        $form->debug('template');
        $form->debug('sendmail');

Message of debugging will be outputted to STDERR. Also. you can log by redirect STDERR with debuglog.pl or other.

When you terminate debugging, you can strip debugging code from this module. All of debugging code are between line of `#>>>DEBUG_CODE'. These are able to strip by striper.pl.

configpara
Debug of parameter

query_string
Debug of parse query string or post data

alias
Debug of alias expand

template
Debug of template expand

sendmail
Debug of sendmail command Do not execute sendmail command. Save to file that is specified in parameter as `redirect'.


SEE ALSO

Params.pm, CGI.pm, MIME::Base64.pm, jcode.pl


AUTHOR

Tetsuya Shigetome, <t_shigetome@muf.biglobe.ne.jp>.


HISTORY

$Revision: 1.3 $
$Log: Mailform.pm,v $ Revision 1.3 2002/11/04 14:16:31 t_shigetome

o Change comments

Revision: 1.2
Log: Mailform.pm,v Revision 1.2 2002/11/04 13:25:47 t_shigetome

o Change manual to english.

o Change to Params.pm from loadparaex.pl And add hash reference arguments to SetParameter.

 Mailform - Create E-mail input form and send E-mail to recipient