Hello, on 09/07/2009 07:47 AM Dave M G said the following: > I am working on a project now where I need to check a POP3 mail account, > download any mails there, and store the body and headers of each > individual mail as plain text in a MySQL database. > > I have downloaded the POP3 class which seems to be the standard class > everyone uses for POP3 mail checking: > http://www.phpclasses.org/browse/package/2.html > > I think I understand how to create an instance of the class and use it > to check the email. The part where you log into the account isn't that > complicated. > > But after that it becomes a little strange. It seems that emails are not > mere text files, but have to be assembled line by line? > > I thought each email, and their headers, would be something I could just > access, download, and pass along to MySQL. But it seems more complicated > than that. > > Has anyone done something like this before? > > If someone could let me know how it is that I can create a body of text > for each email (including the headers) so that I can then store it in > the database, that would be awesome.
If you look at that same package there is a script named browse_mailbox.php that demonstrates how to use the POP3 class to pull messages from the POP3 server and automatically decode them so you can process the messages very easily according to your needs. It returns arrays that list all message parts, including any attachments. From then on, you need to decide which parts of the messages are relevant to you to perform the necessary database INSERT queries to store the message text, HTML, images, attachments, etc.. For this you also need the MIME parser class that is available in the same site: http://www.phpclasses.org/mimeparser You may also want to read this blog post to learn how to use these classes to process the messages conveniently: http://www.phpclasses.org/blog/package/2/post/1-Process-incoming-email-messages-using-PHP.html -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php