PHP imap_fetchmime相当于5.2

I need an function like

imap_fetchmime

For PHP 5.2 (this function is only available on PHP 5.3.6 upwards).

I need the mime headers to decrypt mail however we are still using 5.2 and we are not yet ready to upgrade.

How can I fetch the mime headers in PHP 5.2?

I will be using

openssl_pkcs7_decrypt 

to decrypt the emails.

What does imap_fetchmime return? Could I just use imap_fetchheader and parse it to grab the info I need emulating imap_fetchmime?

Sorted.

I just grabbed the entire header and manually add the mime headers to the top of the p7m file so I can successfully decrypt them.