# This code is provided "as is" with NO WARRANTY expressed or # implied. You may use it freely at your own risk. #!/usr/bin/perl $mail = `cat /var/spool/mail/formmail`; # where each record starsts $delimiter = "-----BEGIN"; @records = split($delimiter, $mail); $num = @records - 1; for (1..$num) { # we lost the delimiter when we split the file # just stick it back on. $record = $delimiter . $records[$_]; # get rid of all the junk between the records $record =~ s/(.*-----END PGP MESSAGE-----\n).*/$1/s; open(RECORD, ">record.tmp"); print RECORD $record; close RECORD; # we hid the clever pass phrase in a file # if we're using GnuPG open(STDIN, 'passcode'); $results = `gpg -d --batch --passphrase-fd 0 record.tmp 2> /dev/null`; close STDIN; # but if using PGP, we pass it on the command line # $results = `cat record.tmp | pgp -fd -z "my clever pass phrase"`; # We'll just print the results to STDOUT, but you # may want to be more creative print $results; }