User Notices:
Message:

 

#### #!/usr/bin/perl -U ############################################################### # # 2001 - smail.pl # Send message to all users of system # ############################################################### #to add users to which you do not wish to send emails, just add email to the dat file (one username per line) $NoSendFile = "donotsend.dat"; $MessageFile = "noticemsg.txt"; $AddrBookFile = "noticemail.dat"; $mailprog = "mail"; # Get information from office ################################### read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); $in =~ s/\+/ /g; $in =~ s/%([a-fA-F0-9][a-dA-F0-9])/pack("C",hex($1))/eg; # Create a new record ######################################### $ParName = "txtMessage"; $ParTrailer = "&Submit=Send Emails"; if (index($in, $ParName) >= 0) { $MessageText = substr($in, index($in, $ParName) + length($ParName) + 1); $MessageText = substr($MessageText, 0, rindex($MessageText, $ParTrailer)); } # Append Message to file ####################################### open(MESSAGE, ">$MessageFile") || die OnError($MessageFile); print MESSAGE $MessageText; print MESSAGE "\n"; close(MESSAGE); # Send message to each address book entry ###################### open RECIPIENT, $AddrBookFile || die OnError($AddrBookFile); open (FH, "$NoSendFile") || die OnError($NoSendFile); @nosendusers = ; close(FH); foreach $nosenduser(@nosendusers) { chop ($nosenduser); } SendPageHeader(); # Open file of users not to send to ############################ while () { $sendto = $_; $sendto =~ s/\n//g; $sendto =~ s/ //g; $send = 0; foreach $nosenduser(@nosendusers) { if ($sendto eq $nosenduser) { $send = 1; } } if ($send eq 0) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$isdst)= localtime(time); if (length($min) == 1) { $min = "0" . $min } if (length($sec) == 1) { $sec = "0" . $sec } $year += 1900; $mon += 1; $time = $mon . "/" . $mday . "/" . $year . " at " . $hour . ":"; $time .= $min . ":" . $sec; $subject = "New Announcement"; $commandLine = $mailprog . " -s \"" . $subject . "\" " . $sendto; $commandLine .= " < " . $MessageFile; system ($commandLine); AppendUserToPage($sendto, $time); sleep 5; } } SendPageTrailer(); close RECIPIENT; # SemdPageHeader Method ####################################### sub SendPageHeader { # print "HTTP/1.0 200 OK\n"; print "Content-Type: text/html\n\n"; print "Send Message Report"; print "The message:

"; $MessageText =~ s/\n/
/g; print $MessageText; print "

was sent to:

"; } # SendPageTrailer Method ###################################### sub SendPageTrailer { print "\n"; } # AppendUserToPage Method ##################################### sub AppendUserToPage # AppendUserToPage(username, time) { my $username = shift(@_); my $currtime = shift(@_); print " " . $username . " on " . $currtime . "
"; } # OnError Method ############################################## sub OnError # OnError(filename) { my $FileName = shift(@_); # print "HTTP/1.0 200 OK\n"; print "Content-Type: text/html\n\n"; print "Send Message Report"; print "

This script has been unable to open the following file: "; print $FileName . "

"; print "

Please make sure the file is not locked by another resource "; print "and try again.

"; print " "; }