Login   Register  
PHP Classes
elePHPant
Icontem

Downloading Content of Multiple Emails

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      POP3 e-mail client  >  All threads  >  Downloading Content of Multiple Emails  >  (Un) Subscribe thread alerts  
Subject:Downloading Content of Multiple Emails
Summary:Should be a simple question - how do you do that?
Messages:5
Author:Patrick Waddingham
Date:2007-03-05 21:09:16
Update:2007-03-07 21:34:50
 

  1. Downloading Content of Multiple Emails   Reply   Report abuse  
Picture of Patrick Waddingham
Patrick Waddingham
2007-03-05 21:09:16
In the parse_message.php file, it has an example that saves the emails to 1, 2, etc. This example only ever pulls one email down at a time. I've tried wrapping that code into a loop, but it only ever gives me 1 email, regardless of how many I actually have in that mailbox.

Is there a way to use that same code to download all of the email from the mailbox?

  2. Re: Downloading Content of Multiple Emails   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2007-03-06 06:11:09 - In reply to message 1 from Patrick Waddingham
The parse_message.php example script is just for demonstrating how to retrieve a message and at the same time parse its contents.

If you just want to retrieve the contents of multiple messages using the same connection, just use the OpenMessage and GetMessage functions for each message after you have opened the POP3 connection.

  3. Re: Downloading Content of Multiple Emails   Reply   Report abuse  
Picture of Patrick Waddingham
Patrick Waddingham
2007-03-07 16:02:37 - In reply to message 2 from Manuel Lemos
I still don't see how to download the contents of multiple e-mails from the same connection.

The Decode function doesn't accept any arguments other than the parameters (and a reference). How do I tell it to parse the data I get from email 1 to N?

  4. Re: Downloading Content of Multiple Emails   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2007-03-07 19:22:57 - In reply to message 3 from Patrick Waddingham
First, open the POP3 connection as usual. Then for each message that you want to receive, use the OpenMessage function to start reading the message, and the GetMessage function repeatedly to retrieve the message data into a string until it reaches the end of message.

If you want to parse the messages, you need to call the MIME parser class Decode function, using the Data parameter to pass the message string. Do not specify the File parameter as you no longer be reading the message from a stream.

  5. Re: Downloading Content of Multiple Emails   Reply   Report abuse  
Picture of Patrick Waddingham
Patrick Waddingham
2007-03-07 21:34:50 - In reply to message 4 from Manuel Lemos
Thank you, Manuel. I totally missed switching from File to Data. This makes a lot more sense now. Once again, thanks for your help!