< web  portfolio >

Brenda C. Mondragon

< Main Page >


PERL :: Password Request Response Script


This Perl script was written to run from the desktop to send out reply e-mails for password requests received from two separate web forms (the form information required manual inspection and approval before the information could be sent). The request information was kept by the server in a data file, which was then read by this script.


The script was written in MacPerl and uses two modules (Mail::Header and Mail::Internet). The excerpt below shows some code from the start of the script and from one of the main subroutines.


#!perl

#################################################################
# PASSWORD REQUEST PROCESSING
#
# This script reads from a password request data file and sends an
# appropriate e-mail response.
#################################################################

use Mail::Header;
use Mail::Internet;

#################################################################
# VARIABLES
#
# Change things in here to customize and set up the script.
#

# the path to the directory where this script and all its files are located (no : on the end)
$basedir = 'XXXX:xxxx:xxxxxx';

# the path to the directory you want to keep log files in
# make sure this directory exists!
$logdir = 'XXXX:xxxx:xxxxxx:logs';

# what data file to read (this file should only contain the ones you want to respond to.. )
$datafile = 'passreq.data';

# file to log actions to - the date and time will be added to the beginning
$logfile = 'passreqlog.txt';

...

#################################################################
# SUBROUTINE WHICH SENDS THE PASSWORD MAIL
# According to AREA REQUESTED for enviro
# Just sends PASS MAIL for navoshnet
sub send_pass {

   $myTo = $linedata[7];
   $myTo =~ s/ //;

   $reqtype = $linedata[21];
   
   if ($reqtype eq 'navoshnet') {

      @myText = @navosh_reply_text;

   } # end of if reqtype navoshnet


   elsif ($reqtype eq 'enviro') {

      # use the reply text (defined above)
      @myText = @reply_text;
      
      # this part takes each area they requested and when it matches something from the passlist array
      # will add the data (title/url/username/password) for it on to the text to be sent
      foreach $area (@areadata) {
      
         if (exists($passlist{"$area"})) {
         
            push(@myText, "$area");
            push(@myText, "\n");
            push(@myText, $passlist{"$area"});
         
         } # end of if

      } # end of foreach area
   
   } # end of elseif
   

   
   # chance to respond to any comments
   if ($comments) {
      &comresp;
   } # end of if comments
   
   push(@myText, "\n\n");
   
   #create headers
   $head = new Mail::Header;
   $head->add('From',$myFrom);
   $head->add('Reply-To',$myFrom);
   $head->add('To',$myTo);
   $head->add('Bcc',$myBcc);
   $head->add('Sender',$mySender);
   $head->add('Subject',$mySubject);
   
   #create mail object
   $int= new Mail::Internet(Header => $head, Body => \@myText);
   
   open(LOG,">>$logdir:$date\.$logfile") || warn && print "$!\n\n";
   
   # send mail & log it
   $success_msg = "PASSWORD MAIL to $myTo ($longdate)\n\n";
   $fail_msg = "***MAIL TO $myTo FAILED ($!)\n\n";
   $int->smtpsend && print($success_msg) && print(LOG $success_msg) || print($fail_msg) && print(LOG $fail_msg);
   
   $int->print( \*LOG );
   print LOG "\n\n";
   print LOG "____________________________________________________________\n";
   close(LOG);
   
} # end of sub send_pass



Categories:



< Main Page >

This portfolio powered by Blosxom

All content Copyright © 1995 - 2024 Brenda C. Mondragon