procmail
[Top] [All Lists]

Extracting variables from perl

2002-01-10 11:00:00
I have a procmail recipie that runs an embedded perl script to remove and store
attachments. I generate a unique filename, but I cannot seem to pass this out
so the following recipie can use it in the email it generates. I have tried
adding to the $ENV hash and also using 'system' to export the value. I don't
know if this is a perl question, or a procmail question, so if this is the
wrong forum, please pardon.
Here is an example of what I am trying to do:

    :0 fw bi
    | perl -p -e ' #\
    $attachment = 1 if /^Content-Disposition\s*:\s.*?attachment/i; #\
    if ($attachment) { #\
    $inattach = 1 if /^\s.*$/; #\
    if ($inattach) {#\
        use Data::UUID qw(:all); #\
        $uuid = new Data::UUID; #\
        ($to) = ($ENV{"TO"} =~ /(^.*)?(_at_)(_dot_)*/); #\
        ($from) = ($ENV{"FROM"} =~ /(.*?)@.*/); #\
        $from =~ s/[\"<>\ ]//g; #\
        $filename = $ENV{"QUARENTINE_DIR"}. "$to-$from.".$uuid->create_str(); #\
        $ENV{"FILENAME"} = $filename; #\
        open (VIRI, ">$filename"); #\
        do { #\
            print VIRI $_;    #\
            $_ = <>;    #\
        } until  (/^\s*$/ || /^--.*/); #\
        $inattach = $attachment = 0; #\
    } #\
    } ' 2>> $LOGFILE

    :0 h i
    | (formail -r \
       -I "To: $TO" \
       -I "From: Procmail Security"; \
       echo ;\
       echo "This is an autoresponce from procmail";\
       echo "It looks like $FROM sent you an email attachment ";\
       echo "that looks suspiciously like a virus";\
       echo "To retrieve this file, please contact NetOps with ";\
       echo "the following filename : ${FILENAME}";\
       echo "Thank you for you patience.";\
   ) | /usr/sbin/sendmail -oi $TO     

If anyone has any ideas, I love to hear them. I don't even know if this is
possible in procmail or not.
-- 
 ________________________________________ 
/ Scott Lillibridge redeye(_at_)wmis(_dot_)net      \
|                                        |
| -- To segfault is human; To bluescreen |
| is moronic.                            |

Attachment: pgpaU9KbJ3jxr.pgp
Description: PGP signature

<Prev in Thread] Current Thread [Next in Thread>