From: root [root@pinot.cciflorida.com] Sent: Monday, July 24, 2006 11:35 AM To: hendra@cciflorida.com Subject: Emailer #!/usr/bin/perl # this is email stuff use CGI qw/:standard/; $reffile = '/var/refcode/email'; $databin = "/home/httpd/databin/" . $ENV{"HTTP_HOST"} ; $sendmailtype = 'sendmail'; $server = 'port.cciflorida.com'; $this = $0; $report = '/home/clients/hendra/emailer'; &recycle; if (param()) { $ref = &GetRefCode; foreach $i (param) { $plisa .= "$i = " . param("$i") . "\n"; $plisb .= qq(
Mailto is to $mailto "; $body =~ s/[\n\r]/\n /g; &Send($mailto, $mailfrom, "$mailsubject", $body); } else { $donotsend = 1; #&Send("sysreport\@cciflorida.com", "root\@cciflorida.com", "Report - Did not sent mass email", "Total recipients: $trep + $tbcc\n"); } } elsif (opendir (DBIN, "$databin")) { $mailto = ""; undef @ccopy; $debug .= "
Found data at $databin\n";
while ($dirc = readdir(DBIN)) {
$debug .= " Failed on both count";
}
&DispHtml($mailfrom, "$mailsubject");
}
} else {
&Debug;
}
print BUG qq( This page is intentionally left blank. Your submission will be process the in order they are received. Please observe the Reference code and you should get a receipt emailed to $mailfrom. ";
print "Back to Main Site";
}
sub DispIncomp {
if (!$failto) {
print header;
} else {
print header(-location=>"$failto");
};
print start_html('Form Incomplete');
print " Your submission is incomplete. Please hit back button and complete your submission. ";
print "Back to Main Site";
}
sub recycle {
my ($c, $d, $fa, $fb, $now);
open (DUG, ">$report/bug.html");
$c = 6;
while (--$c) {
$d = $c + 1;
print DUG "
Found data and will open $databin/$dirc if $dirc contains $maillist";
if (open (MLIST, "$databin/$dirc") && $dirc =~ /$maillist/) {
while ($plisb
);
foreach $k (keys %ENV) {
next if $k =~ /^SERVER/;
print BUG "
$k: $ENV{$k}";
}
sub Debug {
print header,
start_html('CCI Email'),
"Reference code is: $ref
";
print &GetRefCode . "\n" unless $ref;;
foreach $k (keys %ENV) {
print "
$k: $ENV{$k}";
}
print "
\n----
\nTo: $mailto
\n----
\nFrom: $mailfrom
\n----
\nSubject: $mailsubject
\n----Body:
\n$body
\n
\n);
if ($mailto && $mailfrom) {
$mailfrom = " $mailfrom ";
$mailfrom =~ m/\s(\S+\@\S+)\s/;
$mailfrom =$1;
$mailsubject .= "(Re: $ref)" ;
# send email
# filter out return-to, subject, mailto
if (@ccopy) {
my $Cc = join (',',@ccopy);
}
# send to submit
my($sendmail) = ('/usr/sbin/sendmail');
open MAIL, "|$sendmail $mailto" or die "Can't open sendmail: message = '$!'";
print MAIL "To: $mailto\n";
print MAIL "From: $mailfrom\n";
#print MAIL "Cc: $Cc\n" if $Cc;
print MAIL "Subject: $mailsubject}\n\n";
print MAIL "Mail Ref: $ref\nFrom: $mailfrom\n\n";
print MAIL "$body\n";
close MAIL or die "Can't close sendmail: message = '$!'";
# send Receipt
# unless ($note && $note =~ /noreceipt/) {
unless ($donotsend) {
open MAIL, "|$sendmail $mailfrom" or die "Can't open sendmail: message = '$!'";
print MAIL "To: $mailfrom\n";
print MAIL "From: $mailto\n";
print MAIL "Subject: $mailsubject}\n\n";
print MAIL "Mail Ref: $ref\nFrom: $mailfrom\n\n";
if ($receiptnote) {
print MAIL $receiptnote;
} else {
print MAIL "Your submission will be processed in the order it was received. Please save the Reference code.";
}
}
}
}
sub DispHtml {
if (!$returnto) {
print header;
} else {
print header(-location=>"$returnto");
};
print start_html('CCI emailer'),
"Reference code is: $ref
";
print &GetRefCode . "\n" unless $ref;
print "
$c ";
if (-e "$report/$c/body.html") {
$fa = "$report/$c/body.html";
$fb = "$report/$d/body.html";
print DUG "mv $fa $fb";
`mv $fa $fb`;
}
}
open (BUG, ">$report/1/body.html");
$now = `date`;
print BUG "\nThis is $0 on $now
\n";
}