Imap output Problems(please help me)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mrg2007
Forum Newbie
Posts: 3
Joined: Wed Sep 06, 2006 12:30 am

Imap output Problems(please help me)

Post by mrg2007 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


i have problem with output of imap_body function 
when i receive a mail with html form 
i face to additional text around the main of message in email 
for example : 
i send a message(email) by outlook express with html format to my email that i want show by imap_body like this:
Hello World! 

after send a email with outlook express 
i use this code to view my email:

Code: Select all

<?php 
$mail=imap_open("{mrg.name:143/imap}INBOX","myemail","mypassword"); 
echo nl2br(imap_body($mail,$i)); 
imap_close($mail); 
?>
this text view in my output:

Code: Select all

This is a multi-part message in MIME format. 

------=_NextPart_000_0014_01C3EE11.5A3FEF20 
Content-Type: text/plain; 
charset="utf-8" 
Content-Transfer-Encoding: 7bit 

Hello World


------=_NextPart_000_0014_01C3EE11.5A3FEF20 
Content-Type: text/html; 
charset="utf-8" 
Content-Transfer-Encoding: quoted-printable 

xmlns:w=3D"urn:schemas-microsoft-com : office:word" = 
xmlns=3D"http://www.w3.org/TR/REC-html40"> 














style=3D'text-align:left;direction:ltr;unicode-bidi: 
embed'> style=3D'font-size:10.0pt;font-family:Arial'>Hello 
World face=3DArial> lang=3DAR-SA dir=3DRTL = 
style=3D'font-size:10.0pt;font-family:Arial'> dir=3DRTL>! size=3D2 face=3DArial> style=3D'font-size:10.0pt;font-family:Arial'> > 









------=_NextPart_000_0014_01C3EE11.5A3FEF20-- -----------------------
and when i send email in persian language this text will be changed. :x :roll:

but when i receive that email by outlook express just see Hello World string without any additional things :oops:

are there any one whom help me and say to me what shall i do to get correct view message with imap_body

Thank You :wink: :)

feyd | This post didn't need to be ENTIRELY bold.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Code: Select all

imap_fetchbody()
I've never used imap before and yet I am able to tell you the answer to your problem in about 4 seconds. If you use the PHP Manual you too will be able to do the same.
mrg2007
Forum Newbie
Posts: 3
Joined: Wed Sep 06, 2006 12:30 am

Post by mrg2007 »

hi
thanks for your guide
i use it and the additional text removed
but i dont get correct html like that it show in outlook express with attachments :( :cry:
in php manual there isnt good and complete guiding
without a exapmle for these functions: imap_fetchbody-imap_fetchheader - imap_fetchstructure :? :(

cany you help me more?

thanks :roll:
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Post what you are getting and we'll go from there.

I will help with whatever I can but even if I can't there is probably someone who can.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

The IMAP functions seem to have a real problem fetching body parts when attachments are present. I finished up writing my own mail parser for this at work. I'd show the code but I cant because it's stuff from work. If you study the layout of an email body it should be fairly obvious how to parse it though.

You also nneed imap_qprint() to decode quoted printable messages and base64_decode() to decode base64 encoded messages.
mrg2007
Forum Newbie
Posts: 3
Joined: Wed Sep 06, 2006 12:30 am

Post by mrg2007 »

your mind is this 2 function return correct view of html email
imap_qprint and imap_base64
and all of the mail that they received must input to these function to show correctly
what do you suggest for me to learn these functions
becuse i dont have find anything for that

if you can give just a example or sample php code for this work(means show currect html foramt with attachments) i can find out and learn these code
in php manuel i cant find a example for these functions or all of the examples exist doesn't work correctly or doesn't completely

thank you :)
Post Reply