PHP Classes

Decoded array problem

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  Decoded array problem  >  (Un) Subscribe thread alerts  
Subject:Decoded array problem
Summary:Having problem with extrating email address from decoded array
Messages:23
Author:Jack J. Utano
Date:2009-02-27 21:42:39
Update:2009-03-06 18:44:31
 
  1 - 10   11 - 20   21 - 23  

  11. Re: Decoded array problem   Reply   Report abuse  
Picture of Jack J. Utano Jack J. Utano - 2009-03-02 14:38:11 - In reply to message 10 from Manuel Lemos
Thank you for your help again. I made the change and read the part in the documentation about ExtractedAddress which states

"If the extract_addresses variable is set to 1, this entry is set to an associative array with the addresses found in the headers " ...

So, my question is what is the name of the array name `I need to have to print just the addresses stored in the ['EtractedAddresses']['enevlope-to:'] array?

$parameters=array(
'File'=>$message_file,

/* Read a message from a string instead of a file */
/* 'Data'=>'My message data string', */

/* Save the message body parts to a directory */
/* 'SaveBody'=>'/tmp', */

/* Do not retrieve or save message body parts */
'SkipBody'=>1,
'ExtractedAddresses'=>1
);
$mime->address_headers['envelope-to:']=1;
$success=$mime->Decode($parameters, $decoded);
if(!$success)
echo '<h2>MIME message decoding error: '.HtmlSpecialChars($mime->error)."</h2>\n";
else
{
echo '<h2>MIME message decoding successful</h2>'."\n";
echo '<h2>Message structure</h2>'."\n";
echo '<pre>';
print_r($decoded[0]);
print_r($decoded['ExtractedAddrsses']['enevlope-to:']);
echo '</pre>';

  12. Re: Decoded array problem   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-03-02 15:01:45 - In reply to message 11 from Jack J. Utano
You have a typo. You typed ExtractedAddrsses and it its ExtractedAddresses

  13. Re: Decoded array problem   Reply   Report abuse  
Picture of Jack J. Utano Jack J. Utano - 2009-03-02 17:31:51 - In reply to message 12 from Manuel Lemos
OOPS! I have "fat fingures" :) IAC, I corrected the typo and the line of code below yields no email addresses. I view the soucre of the web page and get nothing. So, my question is: is $decoded['ExtractedAddresses']['enevlope-to:'] the place where to get these addresses?

print_r($decoded['ExtractedAddresses']['enevlope-to:']);

Thank you again

  14. Re: Decoded array problem   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-03-02 18:29:14 - In reply to message 13 from Jack J. Utano
Please pay more attention. You typed enevlope-to: instead of envelope-to: .

  15. Re: Decoded array problem   Reply   Report abuse  
Picture of Jack J. Utano Jack J. Utano - 2009-03-02 18:54:26 - In reply to message 14 from Manuel Lemos
I apologize once again. I fixed the typo

print_r($decoded['ExtractedAddresses']['enevlope-to:']);

but still no email addresses....

  16. Re: Decoded array problem   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-03-02 19:16:50 - In reply to message 15 from Jack J. Utano
Please pay more attention. If it does not show the address, that is because you typed it wrong. Verify again until it works because the class works correctly.

  17. Re: Decoded array problem   Reply   Report abuse  
Picture of Jack J. Utano Jack J. Utano - 2009-03-02 20:17:35 - In reply to message 16 from Manuel Lemos
I did fix the typo in the script but I sent you the old line. The line is

print_r($decoded['ExtractedAddresses']['envelope-to:']);

but still no email addresses....

  18. Re: Decoded array problem   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-03-02 22:26:44 - In reply to message 17 from Jack J. Utano
I am using the exact same script you posted. Just added the line to add the envelope-to: header:

$mime->address_headers['envelope-to:'] = 1;

Here is the output of your script. As you may see it shows the address in that header:

Message structure

Array
(
[Headers] => Array
(
[return-path:] =>
[envelope-to:] => [email protected]
[delivery-date:] => Thu, 26 Feb 2009 15:24:37 -0600
[received:] => Array
(
[0] => from exprod5mx233.postini.com ([64.18.0.119] helo=psmtp.com)by server.athenshosting.com with smtp (Exim 4.69)(envelope-from )id 1Lcnif-0002oN-1gfor [email protected]; Thu, 26 Feb 2009 15:24:37 -0600
[1] => from source ([76.96.62.40]) by exprod5mx233.postini.com ([64.18.4.10]) with SMTP;Thu, 26 Feb 2009 13:24:36 PST
[2] => from OMTA09.westchester.pa.mail.comcast.net ([76.96.62.20])by QMTA04.westchester.pa.mail.comcast.net with comcastid LcSx1b0010SCNGk54lQcoJ; Thu, 26 Feb 2009 21:24:36 +0000
[3] => from sz0023.wc.mail.comcast.net ([76.96.58.71])by OMTA09.westchester.pa.mail.comcast.net with comcastid LlQc1b00F1YCShG3VlQczp; Thu, 26 Feb 2009 21:24:36 +0000
)

[date:] => Thu, 26 Feb 2009 21:24:36 +0000 (UTC)
[from:] => [email protected]
[to:] => [email protected]
[message-id:] => <2001997222.2599081235683476676.JavaMail.root@sz0023a.westchester.pa.mail.comcast.net>
[subject:] => Test
[mime-version:] => 1.0
[content-type:] => multipart/alternative; boundary="----=_Part_130292_1857685444.1235683476675"
[x-originating-ip:] => [66.222.12.253]
[x-mailer:] => Zimbra 5.0.11_GA_2730.RHEL5_64 (ZimbraWebClient - IE6 (Win)/5.0.11_GA_2730.RHEL5_64)
[x-pstn-neptune:] => 0/0/0.00/0
[x-pstn-levels:] => (S:99.90000/99.90000 CV: 0.5996 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
[x-pstn-settings:] => 5 (2.0000:2.0000) s CV gt3 gt2 gt1 r p m c
[x-pstn-addresses:] => from [15/1]
)

[Parts] => Array
(
[0] => Array
(
[Headers] => Array
(
[content-type:] => text/plain; charset=utf-8
[content-transfer-encoding:] => 7bit
)

[Parts] => Array
(
)

[BodyPart] => 1
[BodyLength] => 24
)

[1] => Array
(
[Headers] => Array
(
[content-type:] => text/html; charset=utf-8
[content-transfer-encoding:] => 7bit
)

[Parts] => Array
(
)

[BodyPart] => 2
[BodyLength] => 182
)

)

[ExtractedAddresses] => Array
(
[return-path:] => Array
(
[0] => Array
(
[address] => [email protected]
)

)

[envelope-to:] => Array
(
[0] => Array
(
[address] => [email protected]
)

)

[from:] => Array
(
[0] => Array
(
[address] => [email protected]
)

)

[to:] => Array
(
[0] => Array
(
[address] => [email protected]
)

)

)

)

  19. Re: Decoded array problem   Reply   Report abuse  
Picture of Jack J. Utano Jack J. Utano - 2009-03-05 15:11:21 - In reply to message 18 from Manuel Lemos
Thank you. I belive the problem is that I do not understand the var_dump/print_r functions. For example from the out below:

[envelope-to:] => Array
(
[0] => Array
(
[address] => [email protected]
)

)

I am trying to find the array element that contains the email address and use it to update a mysql database. So, my final (I hope) question is: what is the exact aarray point to get the above address.

I thought it might be $decoded['ExtractedAddresses']['enevlope-to:'][0]['address'] but it is not????


print_r($decoded['ExtractedAddresses']['enevlope-to:'][0]['address']);

  20. Re: Decoded array problem   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-03-05 20:36:40 - In reply to message 19 from Jack J. Utano
I suppose you may be dyslexic because you keep switching the order of the letters that you type.

That is OK, but you need to read what you write before asking questions about what is wrong as it is time consuming for me to keep telling you that.

You need to access:

$decoded['ExtractedAddresses']['envelope-to:'][0]['address']

 
  1 - 10   11 - 20   21 - 23