#!/usr/bin/perl ############################################################ # newman - Mike Schilli , 2003 ############################################################ use warnings; use strict; our $VERSION = "1.01"; our $CVSVERSION = '$Revision: 1.4 $'; use Mail::Mailer; use CGI qw(:all); use CGI::Carp qw(fatalsToBrowser); use Text::Wrap qw($columns wrap); $columns = 70; my $body = ""; for my $field (qw(fields from to subject thanks_url)) { die "Mandatory parameter '$field' not set" unless defined param($field); } my @fields = split(/,\s*/, param('fields')); for(@fields) { die "Field $_ missing" unless param($_); my $val = wrap(" ", " ", param($_)); $body .= <new('sendmail'); my $to = shift @to; my @ccline = @to > 0 ? ('Cc', join(', ', @to)) : (); $mailer->open( { From => $from, To => $to, @ccline, Subject => $subject, }); print $mailer $text; $mailer->close; } __END__ =head1 NAME newman - a simple CGI script to send mail from web forms =head1 DOWNLOAD _SRC_HERE_ =head1 SYNOPSIS newman fields="f1,f2" f1=hello f2=world from=from@from.com \ to=to@to.com subject="My Subject" \ thanks_url=http://perlmeister.com/thanks.html =head1 DESCRIPTION B is a CGI script that's meant to be referenced from a HTML form like this:
It will examine the C variable first and extract the comma-separated list of field names from there. Then it will build an email body listing all the different fields specified like f1: hello f2: world and send it to the address given in the C parameter, using the subject line defined in C and the from address given in C. It will use a locally installed C process to deliver the mail. After that's done, it will redirect to the URL given in C, which will typically just display a "Thank you!" page. =head1 LEGALESE Copyright 2003 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR 2003, Mike Schilli