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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 00:40:05
Script start
Timing: Jan 31 2025 00:40:05
Module start 'layout'
Timing: Jan 31 2025 00:40:05
Module start 'content'
Timing: Jan 31 2025 00:40:05
Module end 'content'
Timing: Jan 31 2025 00:40:05
Script end

Main resources:

Total runtime0.0225 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 588.3906151.2422
Module start 'layout' 0.00490.0043 739.6328220.7500
Module start 'content' 0.00930.0117 960.3828997.8672
Module end 'content' 0.02090.0016 1,958.250029.9922
Script end 0.0225  1,988.2422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002812.2645140.0002
Check MTime0.00114.8211140.0001
Mysql Total
Database connection0.00062.828710.0006
Mysqli_queries0.002410.550530.0008
Looping result0.00000.129210.0000
Template Total0.00114.910.0011
Template load0.00093.854510.0009
Template processing0.00021.021610.0002
Override
Cache load0.00062.624410.0006
General
dbfile0.00125.466980.0002
String conversion0.00000.034940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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