Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

Get full email

What php code could I use to connect to a mail server and get the entire raw email?
0
hrolsons
Asked:
hrolsons
  • 3
1 Solution
 
Roger BaklundCommented:
You could use the imap_* functions:

http://php.net/imap
http://www.electrictoolbox.com/php-imap-download-email/
http://php.net/manual/en/function.imap-open.php
http://php.net/manual/en/function.imap-fetchheader.php

This would fetch the entire raw message:

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

From: "XYZ Inc."<vip@xyz.com>

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.

Thanks.


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

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now