#!/usr/bin/perl
#
# mailform perl script
# by Mark van Eijk <mark@luon.net>
#
# redirectpage:	page to redirect to after submitting the form
# mailto:	mailaddress where the form output should go
# subject:	subject of the mail with form-data

use CGI qw/:standard/;
use Mail::Send;
use strict;

my $query = new CGI;
$query->use_named_parameters(1);

my @names = $query->param;

my $mailmsg = new Mail::Send;

my $key;
my $value;
my $redirectpage = $query->param('redirectpage');
my $mailto = $query->param('mailto');
my $subject = $query->param('subject');

$mailmsg->to($mailto);
$mailmsg->subject($subject);

my $mailhandle = $mailmsg->open;

foreach $key (@names)
{
	if ($key eq "redirectpage")
	{
	}
	elsif ($key eq "mailto")
	{
	}
	elsif ($key eq "subject")
	{
	}
	else
	{
		print $mailhandle "$key: ", $query->param($key), "\n";
	}
}

$mailhandle->close;
print "status: 302\n";
print "location: $redirectpage\n";
print "\n";
