Forums / Developer / eZ components MailParser - accessing more from the headers

eZ components MailParser - accessing more from the headers

Author Message

Joe Jenkins

Wednesday 02 May 2007 2:21:42 pm

Hi everyone,

First off, thanks for your efforts. Today is my first time using your components and they are exceptional. I looked here for an answering to the following but had no luck:

When using ezcMailParser(), I can get information out of the headers as follows:

$set = new ezcMailFileSet( array( $currentEmail ));
$parser = new ezcMailParser();
$mail = $parser->parseMail( $set );

$mailFrom = $mail[0]->from;
$mailTo = $mail[0]->to;
$mailCC = $mail[0]->cc;
$mailBCC = $mail[0]->bcc;
$mailSubject = $mail[0]->subject;
$mailTimeStamp = date(DATE_RFC822, $mail->timestamp);
$mailMessageID = $mail[0]->messageId;

This works just fine when I pass in a file of a single email. I need to be able to get more information out of the header, though, and if I print_r($mail) I can see quite a bit of information in there I need for my application. I just don't know how to extract it in PHP. For example,

[map:private] => Array
(
[Return-Path] => <joe@nerdnet.com>
[X-Spam-Checker-Version] => SpamAssassin 3.1.8 (2007-02-13) on rsgmann.x.x
[X-Spam-Level] =>
[X-Spam-Status] => No, score=-3.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, SPF_HELO_PASS autolearn=ham version=3.1.8
[Received] => from 70.96.x.x ([70.96.x.x]) by mail.server.com

I need to be able to get the "Received" field there to grab an IP address out of it, but I can't figure out how to access it inside the object. Can you provide any info on this?

Thanks very much.

Frederik Holljen

Friday 11 May 2007 1:09:43 pm

hi, thank you for using eZ components.

If you take a look at the documentation (http://ez.no/doc/components/view/2006.2/(file)/Mail/ezcMail.html) you'll see the method getHeader() which can be used to fetch any header. ezcMail also inherits ezcMailPart which has the property $headers (http://ez.no/doc/components/view/2006.2/(file)/Mail/ezcMailPart.html). This property can also be used to fetch headers.

For further questions about the components use the mailinglists: http://ez.no/ezcomponents/mailinglists. They are more frequently read by the components developers than the eZ publish forums.

Cheers.

eZ debug

Timing: Jan 30 2025 21:25:25
Script start
Timing: Jan 30 2025 21:25:25
Module start 'content'
Timing: Jan 30 2025 21:25:25
Module end 'content'
Timing: Jan 30 2025 21:25:25
Script end

Main resources:

Total runtime0.1955 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 588.1875370.2578
Module start 'content' 0.00790.0150 958.44531,001.6250
Module end 'content' 0.02290.1725 1,960.07033,893.0859
Script end 0.1954  5,853.1563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00462.3326200.0002
Check MTime0.00140.7004200.0001
Mysql Total
Database connection0.00070.377010.0007
Mysqli_queries0.103052.70391410.0007
Looping result0.00140.72651390.0000
Template Total0.172188.010.1721
Template load0.00090.458510.0009
Template processing0.171287.586510.1712
Override
Cache load0.00060.308010.0006
Sytem overhead
Fetch class attribute can translate value0.00160.843110.0016
XML
Image XML parsing0.00030.140110.0003
General
dbfile0.00502.5658200.0003
String conversion0.00000.002630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs