For everyone who spent lots of time trying to encrypt multipart/alternative emailwith no success:
1.) put complete email (header together with body) into file to encrypt as in example from koen:
<?php
$body = file_get_contents("body.txt");
$msg = $enc_header.$body;
file_put_contents("msg.txt", $msg);
?>
2.) headers array sent to openssl_pkcs7_encrypt can`t contain some of headers, it conflicts/doubles and some clients have problems with it - i.e. Thunderbird don`t show you email body. For me worked headers: "Subject", "To", "From", "Reply-To", "Date","Return-Receipt","Message-ID","CC", "X-Priority", "X-Mailer"
one more thing - if your public key for encryption is not working, check if you are sending certificate with key, not only pure key(must be certificate)
Good luck to everyone, its a little bit hard because of small amount of documentation which is sometimes confusing...