Get full email

What php code could I use to connect to a mail server and get the entire raw email?
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Roger BaklundConnect With a Mentor Commented:
You could use the imap_* functions:

This would fetch the entire raw message:

$msg = imap_fetchheader($stream, $msgno, FT_PREFETCHTEXT);
hrolsonsAuthor Commented:
I didn't think that was working, because I knew that the From should look like this:

From: "XYZ Inc."<>

But all that showed up was "XYZ Inc.".  Then I finally figured out that the "<" and ">" on the email address was causing the page to be confused because it thought it was html.


Roger BaklundCommented:
Yes, use htmlentities() when you need to output this on a html page.
Roger BaklundCommented:
Something like this:
echo '<pre>'.htmlentities($msg).'</pre>';

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.