#!/usr/bin/perl ####################################################### # Email Management System # Created by Aaron Anderson # Contact me at: sulfericacid@qwest.net ####################################################### ######################################## # You may need to configure the following ######################################## my $pw = "test"; ## Change the above to the administrator password my $adminmail = "admin\@test.com"; ## Change the above to the administrator email address (this appears as a Reply-To to the emails you send). ## The \ before the @ is NOT optional my $sendmail = "/usr/lib/sendmail"; ## Change the above to the location of sendmail on your server my $unsub = "list-add.pl"; # unsub link ## Change the above to the location of list-rem.pl on your server ######################################## # Please do not alter anything below this line ######################################## use strict; use warnings; use POSIX; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); require SDBM_File; my $cookiename = "login"; my $favorite = param('flavor'); my $tasty = cookie($cookiename); my $pass = url_param('pass'); my $edituser = url_param('lookup'); my (%sig, %emails); my $sigsave = "sig.dbm"; my $list = "mylist.dbm"; # First check if we saved a cookie last time if($tasty) { print header(-expires=>'now'), start_html("Email Control Panel"); my %snailmail; my $lookup = url_param('lookup'); my $edituser = url_param('edit'); my %snailmail; tie %emails, 'SDBM_File', $list, O_CREAT | O_RDWR, 0644; if ( !tied %emails ) { print "database unsuccessful $!.\n"; } tie %sig, 'SDBM_File', $sigsave, O_CREAT | O_RDWR, 0644; if ( !tied %sig ) { print "database unsuccessful $!.\n"; } #################################################### # Save signature if requested #################################################### if (param('save')) { $sig{'default'} = param('signature'); } ################################################### # Form checking ################################################### if ( param('submit') ) { # rid ourselves from those nasty params my $message = param('message'); my $password = param('password'); my $subject = param('subject'); my $signature = param('signature'); my $save = param('save'); my $use = param('use'); my $time = localtime; if ( $message eq "" || $subject eq "" ) { print "
Your subject or email content was missing.
\n"; #exit; } else { if ( $save eq "yes" ) { print "
"; print "Saving to database...
\n"; $sig{'default'} = $signature; $sig{'stored'} = $sig{'default'}; print "
Your Signature has been saved.

\n"; } print "
\n"; foreach(keys %emails) { my ($name, $add1, $add2, $city, $zip, $country) = split(/::/, $emails{$_}); # Email Subs, special commands my $editmes = $message; # let's not edit $message $editmes =~ s/\[name\]/$name/g; #[name] = user name $editmes =~ s/\[time\]/$time/g; #[time] = time sent $editmes =~ s/\[unsub\]/$unsub/g; #[unsub] = unsubscribe email my $editsig = $signature; # let's not edit $signature $editsig =~ s/\[name\]/$name/g; #[name] = user name $editsig =~ s/\[time\]/$time/g; #[time] = time sent $editsig =~ s/\[unsub\]/$unsub/g; #[unsub] = unsubscribe email my $editsub = $subject; # let's not edit $subject $editsub =~ s/\[name\]/$name/g; # [name] = user name open( MAIL, "| $sendmail -t" ); print MAIL "To: $_\n"; print MAIL "From: $adminmail\n"; print MAIL "Subject: $editsub\n\n"; print MAIL "$editmes\n"; if ($use ne "" && $signature ne "" ) { print MAIL "$editsig\n"; } print MAIL ".\n"; close(MAIL); } my $time = localtime; print "
Email successfully sent on $time
"; } } ################################################### # Begin printing everything ################################################### print <<"ALL";
"; } else { print ""; } print <<"ALL"; ALL if (param('message')) { my $message = param('message'); print ""; } else { print ""; } print <<"ALL";
Email Management - Emailer
Subject:
ALL if (param('subject')) { my $subject = param('subject'); print "
Message:
Signature:

ALL if (exists $sig{'default'}) { print ""; } else { print ""; } print <<"ALL";

Use signature
Save signature

ALL print " "; print end_html(); exit; } # No cookie, so let's print a new form unless ($favorite eq "$pw") { print header(-expires=>'now'), start_html("Email Management- Administrator Login"), hr(), start_form(), p("Please enter your password: ", textfield("flavor",$tasty)), end_form(), hr(); if (param()) { if ($favorite ne "$pw") { print "Wrong password!"; exit; } exit; } exit; } # Favourite value was '$pass', save cookie to browser my $cookie = cookie( -NAME => $cookiename, -VALUE => $favorite, #-PATH => "/", -EXPIRES => "+2y", ); print header(-COOKIE => $cookie, -expires=>'now'); print start_html("Email Control Panel"); tie %emails, 'SDBM_File', $list, O_CREAT | O_RDWR, 0644; if ( !tied %emails ) { print "database unsuccessful $!.\n"; } tie %sig, 'SDBM_File', $sigsave, O_CREAT | O_RDWR, 0644; if ( !tied %sig ) { print "database unsuccessful $!.\n"; } ################################################### # Begin printing everything ################################################### print <<"ALL";
"; } else { print ""; } print <<"ALL"; ALL if (param('message')) { my $message = param('message'); print ""; } else { print ""; } print <<"ALL";
Email Management - Emailer
Subject:
ALL if (param('subject')) { my $subject = param('subject'); print "
Message:
Signature:

ALL if (exists $sig{'default'}) { print ""; } else { print ""; } print <<"ALL";

Use signature
Save signature

ALL print end_html(); exit;