#!/usr/bin/perl # Copyright 2004 Boutell.Com, Inc. Compatible with our earlier C program. use CGI; my $sendmail = "/usr/sbin/sendmail"; my $emailConfPath = "nieuwsbrief.conf"; my $query = new CGI; my $recipient = &clean($query->param('recipient')); my $subject = &clean($query->param('subject')); my $nieuwsbriefnaam = &clean($query->param('nieuwsbriefnaam')); my $nieuwsbriefemail = &clean($query->param('nieuwsbriefemail')); if (($nieuwsbriefnaam eq "") || ($nieuwsbriefemail eq "")) { &error("Email Rejected", "Please fill out all fields provided. Back up to the " . "previous page to try again."); } if (!open(IN, "$emailConfPath")) { &error("Configuration Error", "The file $emailConfPath does not exist or cannot be " . "opened. Please read the documentation before installing " . "email.cgi."); } my $returnpage; my $ok = 0; while (1) { my $recipientc = ; $recipientc =~ s/\s+$//; if ($recipientc eq "") { last; } my $returnpagec = ; $returnpagec =~ s/\s+$//; if ($returnpagec eq "") { last; } if ($recipientc eq $recipient) { $ok = 1; $returnpage = $returnpagec; last; } } close(IN); if (!$ok) { &error("Email Rejected", "The requested destination address is not one of " . "the permitted email recipients. Please read the " . "documentation before installing email.cgi."); } # Open a pipe to the sendmail program open(OUT, "|$sendmail -t"); # Use the highly convenient <redirect($returnpage); exit 0; sub clean { # Clean up any leading and trailing whitespace # using regular expressions. my $s = shift @_; $s =~ s/^\s+//; $s =~ s/\s+$//; return $s; } sub error { # Output a valid HTML page as an error message my($title, $content) = @_; print $query->header; print < $title

$title

$content

EOM ; exit 0; }