Solved

Get full email

Posted on 2009-07-01
5
223 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now