PHP Classes
elePHPant
Icontem

Working with MIME Email Message Parser Decode output.

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  Working with MIME Email Message...  >  (Un) Subscribe thread alerts  
Subject:Working with MIME Email Message...
Summary:Do I have to regx to get more?
Messages:12
Author:Fat Katie
Date:2019-09-10 20:42:33
 

 

  1 - 10   11 - 12  

  1. Working with MIME Email Message...   Reply   Report abuse  
Fat Katie - 2019-09-10 20:42:33
I've collected my message and written it to a file. It serves as
input to decode. A print_r on the decoded return gives:

Array
(
[0] => Array
(
[Headers] => Array
(
[received:] => from SN6PR13MB2496.namprd13.prod.outlook.com (2603:10b6:4:1::23) by
)

[Parts] => Array
(
)

[Position] => 0
[DecodedHeaders] => Array
(
[received:] => Array
(
[0] => Array
(
[0] => Array
(
[Value] => from SN6PR13MB2496.namprd13.prod.outlook.com (2
[Encoding] => UTF-8
) ) ) ) ) )

In [received:] there's a substring '...Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: quoted-printableThis really is the body.=C2=A0 An at'

How do I collect the body text of the message? Do I have to work the strings within the array? I would have thought 'Content-Type' would have been another key.

Thank you.

  2. Re: Working with MIME Email Message...   Reply   Report abuse  
Manuel Lemos - 2019-09-10 21:02:59 - In reply to message 1 from Fat Katie
In the parameters that you pass to the Decode function, do not pass the value 'SkipBody' .

  3. Re: Working with MIME Email Message...   Reply   Report abuse  
Fat Katie - 2019-09-10 22:30:42 - In reply to message 2 from Manuel Lemos
Tried this:


$parameters = array('File'=>'testfile.out');
$decoded = array();
unset($parameters['SkipBody']);
if(!$mime->Decode($parameters, $decoded))


No joy.

If this is correct, then the mail file must be damaged; even though your test script shows a proper listing. I hack some more. I may be back.

Thank you.

  4. Re: Working with MIME Email Message...   Reply   Report abuse  
Manuel Lemos - 2019-09-10 22:45:13 - In reply to message 3 from Fat Katie
If you can post the script you are using and the MIME message data file you are trying to parse, I can try and check what is wrong.

  5. Re: Working with MIME Email Message...   Reply   Report abuse  
Fat Katie - 2019-09-11 13:30:42 - In reply to message 4 from Manuel Lemos
It must be something I'm writing. The body text is still buried in a string

if(($error=$pop3->RetrieveMessage(1,$headers,$body,-1))=="") {

for($line=0;$line<count($headers);$line++) {
$str = $headers[$line];
fwrite($fh, $str);
}

for($line=0;$line<count($body);$line++) {
$str = $body[$line];
fwrite($fh, $str);

I'll try a different parser. That will tell me. Thanks for your help.

  6. Re: Working with MIME Email Message...   Reply   Report abuse  
Fat Katie - 2019-09-11 14:01:44 - In reply to message 5 from Fat Katie
clipped this from php ... just to be sure

function fwrite_stream($fp, $string) {
for ($written = 0; $written < strlen($string); $written += $fwrite) {
$fwrite = fwrite($fp, substr($string, $written));
if ($fwrite === false) {
return $written;
}
}
return $written;
}

  7. Re: Working with MIME Email Message...   Reply   Report abuse  
Fat Katie - 2019-09-11 16:11:38 - In reply to message 6 from Fat Katie
hostname="outlook.office365.com"

Message format doesn't play. Yahoo mail acts quite different, although I'm still not getting what I'd expect. This is knowledge issue on my part.

Issue closed.

Thank you for your help

  8. Re: Working with MIME Email Message...   Reply   Report abuse  
Manuel Lemos - 2019-09-11 18:37:47 - In reply to message 5 from Fat Katie
It seems the problem is that you are not adding the line break characters when you are joining the header and body lines.

Try changing this:

$str = $headers[$line];

to this:

$str = $headers[$line]."\r\n";

And this:

$str = $body[$line];

to this:

$str = $body[$line]."\r\n";

But there is an even better way to pull messages from the POP3 server and pass them to the MIME parser class.

You can use the POP3 stream handler provided by the POP3 package and use like a file name of a regular file, so the POP3 class internally retrieve the message data as if it were a real file.

Read this tutorial article for more information:

phpclasses.org/blog/package/2/post/ ...

  9. Re: Working with MIME Email Message...   Reply   Report abuse  
Fat Katie - 2019-09-11 19:43:18 - In reply to message 8 from Manuel Lemos
Much better.
You have a donate link?

Tried a few permutations with the stream. No luck so far.
Thank you.

  10. Re: Working with MIME Email Message...   Reply   Report abuse  
Manuel Lemos - 2019-09-12 19:57:55 - In reply to message 9 from Fat Katie
So, does it work OK now?

 
  1 - 10   11 - 12