Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get full email

Posted on 2009-07-01
5
Medium Priority
?
270 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses four methods for overlaying images in a container on a web page
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

722 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