Solved

Get full email

Posted on 2009-07-01
5
266 Views
Last Modified: 2012-05-07
What php code could I use to connect to a mail server and get the entire raw email?
0
Comment
Question by:hrolsons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 24756005
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
 

Author Comment

by:hrolsons
ID: 24756099
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
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24756124
Yes, use htmlentities() when you need to output this on a html page.
0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24756132
Something like this:
echo '<pre>'.htmlentities($msg).'</pre>';

Open in new window

0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question