Hello All,

   Can anyone with some extensive PERL knowledge take a look at this file and let me 
know why this may not be working?  It is supposed to take an e-mail and parse out the 
subscription information for a e-mail list then send that information onto the List 
Server to Process.

   This script was written by IPSwitch, yet a couple of us users are nat able to get 
this script to work.  I am not a Perl nut, so I am not able to find anything obvious.

Thanks,
Grant Griffith
http://www.getafreewebsite.com




#############################################################################
# imailsrv2.pl
# Copyright (C) 1999 Ipswitch, Inc.
#
# Ipswitch Inc, grants any valid licensee of IMail for Windows NT the right
# to modify this source and use the modified version of software generated
# from the source with any implementation of IMail for Windows NT.
# 
# NOTE: The information in this file is for experienced Perl developers 
# to use to extend the capabilities of IMail Server.  It is beyond 
# the scope of this document and Ipswitch technical support to provide any 
# guidance on writing Perl scripts.
# 
#############################################################################

# Version Information ------------------------- #
$version = "1.0"; # ---------- #

# Program Definition ------------------------- #
# This script works with the new version of imailsrv2.pl. It reads in the body text of 
the user's e-mail and scans for a user action
# (such as subscribe, set mode, or unsubscribe). It then resends these lines to the 
list server
# --------------------------------------------- #

# get the email text file name from command line
$filename=$ARGV[0];
$counter = "False";
$Line = "False";

# open the file, read in the contents, and check for any action lines. Put any action 
lines into the @subscribe array
  if ( open ( FILE, "<$filename" ) ) {
        while (<FILE>) {
                if ($_ =~ /======Please Do Not Edit Below This Line======/) {
                        $Line = "True";
                } elsif (($_ =~ /subscribe|set mode digest|unsubscribe|set mode 
standard/i) && ($Line eq "True")){
                        $_ =~ s/[^a-zA-Z_\s]//g; # get rid of anything that isn't a 
word or a space
                        $_ =~ s/^\s+//; # get rid of any leading spaces
                        push(@subscribe, $_);
                        $counter = "True";
                } elsif ($_ =~ /Dear/i) {
                        $_ =~ s/Dear//i;
                        $_ =~ s/\://g;                          
                        $_ =~ s/ //g;
                        $_ =~ s/\>//g;
                        $Email = $_;
                }
        }
        
  } else {
                ######### STEP 1 - ENTER YOUR PROGRAM ALIAS ##########
                $email_results = `imailcgi suberror.txt -t $Email -f [EMAIL PROTECTED] 
-s "Discussion List Error"`;
                exit(0);
  }

unlink $filename;

if ($counter eq "False") {
        ######### STEP 2 - ENTER YOUR PROGRAM ALIAS ##########
        $email_results = `imailcgi nochange.txt -t $Email -f [EMAIL PROTECTED] -s 
"Discussion List Error"`;
} else {

        ($seed1, $seed2, $seed3, $seed4) = split (/\./, $ENV{'REMOTE_HOST'}, 4);
        $seed = $seed1 + $seed2 + $seed3 + $seed4;
        
        $random_number = rand $seed;
        $random_number =~ s/\.//;

        ######### STEP 3 - ENTER THE PATH TO YOUR TEMP DIRECTORY ##########
        $temp_file = "c:\\temp" . "\\su$random_number" . ".txt";

        if ( open (BODY,">$temp_file") ) {
                if (-W $temp_file) {
                        foreach $line (@subscribe) {
                                print BODY "$line\n";
                        } #end foreach
                } # End IF
                else {
                        ######### STEP 4 - ENTER YOUR PROGRAM ALIAS ##########
                        $email_results = `imailcgi suberror.txt -t $Email -f 
[EMAIL PROTECTED] -s "Discussion List Error"`;
                        exit(0);
                } # End ELSE
                
        } else {
                ######### STEP 5 - ENTER YOUR PROGRAM ALIAS ##########
                $email_results = `imailcgi suberror.txt -t $Email -f [EMAIL PROTECTED] 
-s "Discussion List Error"`;
                exit(0);                
        } # End ELSE


        close (BODY);

        ######### STEP 6 - ENTER YOUR LIST SERVER ADDRESS ##########
        $email_results = `imailcgi $temp_file -t [EMAIL PROTECTED] -f $Email`;

        unlink $temp_file;
}

Reply via email to