PHP Classes

how to parse multiple messages?

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  how to parse multiple messages?  >  (Un) Subscribe thread alerts  
Subject:how to parse multiple messages?
Summary:possible to read multiple messages from a mail spool file?
Messages:4
Author:Taz Landragon
Date:2009-08-26 10:11:36
Update:2009-08-27 03:58:51
 

  1. how to parse multiple messages?   Reply   Report abuse  
Picture of Taz Landragon Taz Landragon - 2009-08-26 10:11:36
hi,

my current situation here is that I've to read mails from gmail via pop then parse the messages.
The problem is that my server doesn't have OpenSSL which is required for gmail.
So I had to use fetchmail to get new mails from gmail.

Basically, fetchmail just sends all emails to /var/spool/mail/myname

That's the file i wish to parse.

Tried mimeparser, but somehow it only parses the first message.

the $decoded array is always size 1.

Is there something that needs to be done to enable it to parse all messages?

Thanks.

  2. Re: how to parse multiple messages?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-08-26 18:50:58 - In reply to message 1 from Taz Landragon
I suspect that messages are stored in the mbox message format.

Anyway, if size of decoded variable is 1, probably it is not even an array. You need to show the actual variable contents to understand what is going on.

  3. Re: how to parse multiple messages?   Reply   Report abuse  
Picture of Taz Landragon Taz Landragon - 2009-08-27 02:21:53 - In reply to message 2 from Manuel Lemos
I see. It's in mbox format.
I have set mbox = 1 and it is able to parse the multiple messages. Thanks.

Is it safe to assume that for mbox format, the first line of the email is always "From [email protected] somedatetime", while a non-mbox format always starts with "Return-path: [email protected]"?

  4. Re: how to parse multiple messages?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-08-27 03:58:51 - In reply to message 3 from Taz Landragon
Yes, the From header is not valid in common messages because it does not have a colon : . It is also escaped in lines that may start with From word to avoid confusion with the real start of next message. That is why it is used a separator.