Solved

Get full email

Posted on 2009-07-01
5
247 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
  • 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
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 24756135
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

828 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