Forum Moderators: coopster

Message Too Old, No Replies

IMAP : Output the whole source of an email

imap imap_fetchheader file attachment scan

         

humandesigner

9:11 pm on Apr 21, 2004 (gmt 0)

10+ Year Member




Hello,

I need to know if there is any way I could output THE WHOLE source of an email into one single string by using IMAP functions.

I'm using imap_fetchheader and imap_fetchbody but information such as attachments' extensions are always missing.

I guess I should use imap_fetchstructure instead, but the documentation being undetailed, I can't produce anything worthable with this function.

Actually, I just need to emulate the "view message source" of Outlook so that the PHP code could detect nasty file extensions such as :

Content-Disposition: attachment;
filename="message.exe"

Thanks for helping! :)

bcolflesh

9:18 pm on Apr 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



imap_fetchbody should have the attachment info - if you look here:

[php.net...]

You can use that command to test for attachments (but it looks tricky, as attachments can be implemented various ways by various sending clients).

Some more code to examine here:

[linuxscope.net...]

humandesigner

3:11 pm on Apr 22, 2004 (gmt 0)

10+ Year Member



Ok, here is the most simple way I've found to scan emails for nasty files :

$mess_structure = print_r(imap_fetchstructure($mbox, $i), true);

for( $j=0; $j < sizeof($bad_file_array); $j++ ) {

if( stristr($mess_structure, $bad_file_array[$j]) ) imap_delete($mbox, $i);

}

imap_close($mbox, CL_EXPUNGE);