note 68097 added to function.imap-fetchbody

From: Date: Thu, 13 Jul 2006 05:04:46 +0000
Subject: note 68097 added to function.imap-fetchbody
Groups: php.notes 
Request: Send a blank email to php-notes+get-114723@lists.php.net to get a copy of this message
For those of you trying to create a "flexible" email reader, I suggest doing the following. Firstly, instead of going through each part of the email and decoding it, I suggest you go in a specific order. 1) First go through all the parts and search for the part that has subtype=='HTML'. If found, use that as your message body, else go to Step 2. 2) If HTML component not found, search all parts for subtype=='PLAIN'. If found, use that as your message body else print out an error message (this should never occur). 3) At this point, you already have the main body of the email that you should display. The next thing to do is to find all the attachments. You do this by going through all parts, searching for the parts with ifdisposition==1 (there can be multiple). This is the way I did my email reader program and it works perfectly. I started off by using the methods recommended in a lot of webpages (i.e. going through the parts tree like 1.2.1, 1, 2, etc) but the problem is the message body is never in some fixed part! Sometimes its in 1, somtimes 1.1.2, sometimes 2, and sometimes in some totally unexpected place! So my approach was to "search" for the parts that I'm interested. Hope this helps. I also managed to crack the problem with emails containing embedded images. I will probably write a tutorial on that soon. ---- Server IP: 64.71.164.2 Probable Submitter: 69.172.48.141 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.imap-fetchbody.php Edit -- http://master.php.net/note/edit/68097 Del: integrated -- http://master.php.net/note/delete/68097/integrated Del: useless -- http://master.php.net/note/delete/68097/useless Del: bad code -- http://master.php.net/note/delete/68097/bad+code Del: spam -- http://master.php.net/note/delete/68097/spam Del: non-english -- http://master.php.net/note/delete/68097/non-english Del: in docs -- http://master.php.net/note/delete/68097/in+docs Del: other reasons-- http://master.php.net/note/delete/68097 Reject -- http://master.php.net/note/reject/68097 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114723) next »