Hi i need help im trying to retrieve the body and subject line of an email aswell as possibly the date it was recieved. i dont want any other information from the email but would be nice to limit results to 3/4 latest emails.
[php]
[/php]
Hi i need help im trying to retrieve the body and subject line of an email aswell as possibly the date it was recieved. i dont want any other information from the email but would be nice to limit results to 3/4 latest emails.
[php]
[/php]
Well, as far as I know, you just use the imap_body() function to read the “body” of the current email. But, I am
sure this pulls the entire email. To pull out a section of the email, you need to use the imap_fetchbody() function
and set it’s argument to load the parts needed.
Here is the PHP.net list of functions available to you:
http://php.net/manual/en/ref.imap.php
Here is the fetchbody function: (See notes down a bit on this page which talk about loading parts of the body…
http://php.net/manual/en/function.imap-fetchbody.php
Now to pull out info such as the subject, who it came from, the date sent or other data, you need to pull out
the headers of the email into an object and then display or use the info you want. To do this you need to use
the headerinfo functions. Look at this function here: (NOTE: Go down to almost the end of this page and look
at the section with a lot of red in it where they show an example of the headerinfo function and how to display
the outputs of it. I think this is what you really need for your project… )
http://php.net/manual/en/function.imap-headerinfo.php
this helped a lot thanks.
Glad you solved it! See you in your next puzzle…