in reply to Error reading S/MIME message with openssl

Does the error occur without using Perl as well?

What is the output if you run the following command on the shell (with the variables replaced by the values in your Perl program):

$OPENSSL smime -decrypt -in $mailfile -recip $RECIP_CERT -inkey $RECIP +_KEY -passin pass:$RECIP_PASSWORD

If you get the same output there, the problem is with $OPENSSL or with the client input and has nothing to do with Perl.