#!/usr/bin/perl # # $Id: maillib.pl,v 1.2 2004/01/13 19:22:04 jeffo Exp $ # # Source File: maillib.pl use Net::SMTP; #sub send_mail { # open(SENDMAIL, "|/usr/lib/sendmail -oi -t") # or $msg2 = "Can't fork for sendmail: $!\n"; # print SENDMAIL <<"EOF"; #From: $_[0] #To: $_[1] #Subject: $_[2] # # # #$_[3] #EOF #close(SENDMAIL) or $msg2 = "sendmail didn't close nicely"; #} sub send_mail { $subj = $_[2]; if ( $subj =~ /\:/) { $maildir = join( $pathsep, $pubroot, $SESSION{'clid'}, "notify"); $mmdate = &format_date_time("dd-mmm-yyyy", time, "0"); $mmtime = &format_date_time("hh:nn:ss", time, "0"); $filename=join(' ', $_[2],$mmdate,$mmtime); $filename =~ s/ /_/g; $trash = join( $pathsep, $maildir, $filename); if (open( MAILFILE, ">$trash" )) { print MAILFILE "From:$_[0]\nTo: $_[1]\nSubject: $_[2]\n$_[3]\n"; close MAILFILE; } } #v wac add ability to send to a list of recipients 6/18/02, adapt W2K fix from 8/21/01 @recipients = split(/\,/, $_[1]); $trash = join( $pathsep, $secroot, "debug.txt"); open( DBGFILE, ">>$trash" ) || return 0; $smtp = Net::SMTP -> new ($mail_server_domain, Timeout => '60' ); print DBGFILE "MAIL: mark\n"; #print DBGFILE "MAIL: new\n"; $smtp-> mail ("$_[0]"); #print DBGFILE "MAIL: from\n"; foreach $recipient (@recipients) { $smtp-> recipient ("$recipient", Skipbad => TRUE); } #print DBGFILE "MAIL: recips specified\n"; $smtp-> data(); $smtp -> datasend ("From: $_[0]\nTo: $_[1]\nSubject: $_[2]\n$_[3]"); $smtp -> dataend; #print DBGFILE "MAIL: data\n"; $smtp -> quit; #print DBGFILE "MAIL: done\n"; close DBGFILE; } #wac ^ replaced whole subroutine, had to adapt to retain debug statements. sub send_illegal_attempt { my $capturedenv = ""; for (keys %ENV) { $capturedenv = join('', $capturedenv, "$_ = $ENV{$_}\r\n"); } my $capturedForm = "" ; for (keys %FORM) { $capturedForm .= "$_ = $FORM{$_}\r\n" ; } $mmdate = &format_date_time("dd-mmm-yyyy", time, "0"); $mmtime = &format_date_time("hh:nn:ss", time, "0"); $mmsubj = "ILLEGAL ACCESS ATTEMPT"; $mmbody = "Date: $mmdate An illegal attempt to access the site has occurred. USER_AGENT: $ENV{'HTTP_USER_AGENT'} REMOTE_ADDR: $ENV{'REMOTE_ADDR'} HTTP_REFERER: $ENV{'HTTP_REFERER'} REQUEST_METHOD: $ENV{'REQUEST_METHOD'} SERVER_PORT: $ENV{'SERVER_PORT'} QUERY_STRING: $qstr ENVIRONMENT: $capturedenv FORM: $capturedForm "; &send_mail($mmautontfyfrom, $mmautontfyto, $mmsubj, $mmbody); } # end with True because this is a require file 1