Turn your Mobile Apps into m-commerce apps – Learn More!

You're Browsing As A Guest! Register Now...
Become a PHP Expert!

Join 415,728 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,705 people online right now.Registration is fast and FREE... Join Now!



Gmail and IMAP Message Body Rate Topic: -----

#1 animedude123  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 03-August 07


Dream Kudos: 0

Share |

Gmail and IMAP Message Body

Posted 06 December 2008 - 10:34 PM

Hey,

I am currently using a php script to grab my new gmail emails and I've managed to get the date, who it is from, who it is to, and the subject (thanks to the internet).

I got that by grabbing the header info with imap:

$obj_thang = imap_headerinfo($m_mail, $what_ever);


Then just use something like:

$obj_thang->fromaddress


to get who it is from.

I can't find a way though to get the actual body of the email. I'm new to imap and the only reason I've got what I have is because I managed to find pieces of it on the internet.

So does anyone know how to get the body of the email? Also if anyone knows what to do to delete a message, that would be nice too :D

Thanks in advance for any help!

This post has been edited by animedude123: 06 December 2008 - 10:55 PM

Was This Post Helpful? 0
  • +
  • -


#2 Hary  Icon User is offline

  • D.I.C Regular
  • PipPipPip

Reputation: 43
  • View blog
  • Posts: 425
  • Joined: 23-September 08


Dream Kudos: 0

Re: Gmail and IMAP Message Body

Posted 07 December 2008 - 02:11 AM

How about imap_body()
Was This Post Helpful? 0
  • +
  • -

#3 animedude123  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 03-August 07


Dream Kudos: 0

Re: Gmail and IMAP Message Body

Posted 07 December 2008 - 10:51 AM

Ok, that sorta worked. I can get the main message from that, but I'm also getting some other parts...

Some emails I get things like "Content-Type" and things like that.

Is there a way to get only the message part of the email?

I tried using imap_fetchbody($m_mail, $what_ever, 2) because I thought that might work, and 2 I thought might be the message (saw it on fetchstructure reference page)

That didn't work though...

EDIT: Ok, got it I think :D Mostly at least.

imap_fetchbody($m_mail, $what_ever, 2) I think is getting me the html format of an email (that is why it is sometimes showing up empty on some emails) EDIT: Nevermind, 2 just gives me this encoded stuff that doesn't make any sense to me xD At least when the message has an attachment in it lol

and then

imap_fetchbody($m_mail, $what_ever, 1) gets me the plain text version of the email. EDIT: This gives me the normal message. If it comes with images and html, this will display it.

Both leave off those header things for the body though :D

Still not sure how to delete messges though...Or mark them as read. If anyone knows how to do that, that would be the next thing I'm trying to do :D

This post has been edited by animedude123: 07 December 2008 - 11:13 AM

Was This Post Helpful? 0
  • +
  • -

#4 Hary  Icon User is offline

  • D.I.C Regular
  • PipPipPip

Reputation: 43
  • View blog
  • Posts: 425
  • Joined: 23-September 08


Dream Kudos: 0

Re: Gmail and IMAP Message Body

Posted 07 December 2008 - 10:57 AM

The manual page I posted tells you how to handle that:

imap_body() will only return a verbatim copy of the message body. To extract single parts of a multipart MIME-encoded message you have to use imap_fetchstructure() to analyze its structure and imap_fetchbody() to extract a copy of a single body component.

The imap_fetchstructure manual page has some nice examples in the user comments, try to use them as a guideline!
Was This Post Helpful? 0
  • +
  • -

#5 animedude123  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 03-August 07


Dream Kudos: 0

Re: Gmail and IMAP Message Body

Posted 07 December 2008 - 04:33 PM

Thanks, taking a quick look at the comments seems like I will be able to get an idea of how to make the functions I'm looking for :D

Never knew IMAP was so useful :P
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users