Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 14th, 2004, 06:09 AM
Registered User
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default imap_fetchbody problem

Hi all!

I'm trying to fetch email message from my mailbox...
Everything works fine, except when i fetch message body of emails having attachment.

I'm using the function below to fetch message body..
$arrbody = imap_fetchbody($this->stream, $this->msg_uid, 1, FT_UID);

Using this function, i got the message body of email without attachment as:

Hi... test message.. please ignore.


and message body for email with attachment, i got:

------=_NextPart_001_0067_01C49A60.EC5D6C60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Hi... test message.. please ignore.=20

------=_NextPart_001_0067_01C49A60.EC5D6C60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

charset=3Diso-8859-1">

Hi... test message.. please ignore.
------=_NextPart_001_0067_01C49A60.EC5D6C60--



I tried lot but could not resolve this.

Please help.

Thanks

Manish


 
Old September 14th, 2004, 06:36 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

imap_fetchbody uses a complicated algorithm of assigning part numbers to each message part. So complicated I've personally spent almost a year, off and on, studying it. It doesn't behave the same between different message structures. However, it does behave predictably and consistently, if that makes sense. I have written a whole PEAR package using it and the rest of the c-client extension as a backend. So that said, you are welcomed and encouraged to use my Mail_IMAP PEAR package!

You can find the latest version, source code, extended documentation, etc at my website:
http://www.smilingsouls.net/index.ph...ail_IMAP/index

As for explaining how imap_fetchbody works, you've found the right person to ask, but I don't have time at the moment to go into detail on it, this being an immensely complicated topic. The short answer is, imap_fetchbody is closely related to imap_fetchstructure, so that'd be the place to start. The premise is certain message parts are supposed to be ignored in certain situations. So to get a handle on it, have a look at the source of Mail_IMAP. If you have more questions after looking over Mail_IMAP, I would be happy to answer them.

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old March 1st, 2006, 07:13 AM
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mitulkoradia
Default


Hi manish

This is the same problem of mine but now i am solved this problem
so dont worry for that

for that i am developed one class for the Mail reciving
by using that class you can read all mail in any format and also u can download mail atteched file.

Just download this class from this location

i post this class in phpclasses.og but this is waitng for approval
if you want this class urgently then mail me on mitulkoradia@gmail.com

other wise take from http://www.phpclasses.org/browse/class/2.html

Cheers
Mitul:)

koradia Mitul
cell : +91 9879697592
 
Old May 9th, 2008, 08:51 AM
Registered User
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Mitul,

I did downloaded your class file and used it in Drupal. Everything is working fine except I am getting "=20" characters in body. Please help me in solving this.

Thanks in advance,
Chandra
 
Old May 9th, 2008, 06:10 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> I am getting "=20" characters in body. Please help me in solving this.

That means the message is encoded as "quoted-printable". There are other types of encoding used as well.

You need to detect the encoding in the message and decode it.

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design, 2nd Edition
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
 
Old May 10th, 2008, 11:01 AM
Registered User
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Mr.Richard. I will check it once more.

Regards,
Chandra









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.