#!/usr/bin/perl # # Filename: mailto-nodb.cgi # Author: Anon # Date: 17/12/98 # Last Modified: 06/07/00 # Version: 3.0 # # Description: # # This script is used to send an email to someone # with information gleaned from a CGI form. # It accepts a subject for the email, to, cc and bcc fields # as well as names for the pages to display upon success and failure. # # This script expects # a _to field (the mail address of the destination mailer) # a _subject field # any number of _cc and _bcc fields # # _success_url - the webpage to go to once the mail has been sent # _fail_url - the webpage to go to if the mail fails. # # # Any other input parameters not beginning with an '_' are appended to # the mail message, this means you should call the submit buttons etc _submit, # or you'll get them appended to the mail message. # # Any input parameters that begin with '++' HAVE to be filled in or you get # redirected to the _fail_url # # -------------------------------------------------------------------------------------------- # # Copyright (c) 1998 - 2000 ComputerTorture # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # -------------------------------------------------------------------------------------------- use CGI; use CGI::Carp qw (fatalsToBrowser); use strict; require Mail::Send; while(my $query = new CGI) { handle_request($query); exit(0); } sub handle_request { my $query = shift; my @param_list = $query->param; # Check the fields that must be filled in.... foreach my $name (@param_list) { if ($name =~ /^\+/ and $query->param(-name => $name) !~ /\S/) { print $query->redirect(-uri => $query->param(-name => '_fail_url')); return; } } # Get the cc and bcc fields: my @cc_list = $query->param(-name => '_cc'); my @bcc_list = $query->param(-name => '_bcc'); my $msg = new Mail::Send; $msg->to($query->param('_to')); $msg->subject($query->param('_subject')); foreach (@cc_list) { $msg->cc($_); } foreach (@bcc_list) { $msg->bcc($_); } my $fh = $msg->open; foreach my $name ($query->param) { next if $name =~ /^_/; my $value = $query->param(-name => $name); $name =~ s/^\+//; $value =~ s/^on/yes/; print $fh "\n$name:\n" . $value . "\n"; } $fh->close; print $query->redirect(-uri => $query->param(-name => '_success_url')); }