On Mon, Sep 07, 2009 at 07:47:00PM +0900, Dave M G wrote: > PHP List, > > 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.
I don't know what your class is doing, but yes, emails are very simple in structure. Everything above the first bare newline (nothing else on that line) is header, and everything below it is body. Even mime-encoded attachments are just part of the body and can be stored as plain text. Your class may be parsing the emails and assigning various parts of them to various class members. But emails are downloaded as a stream of bits, sequentially, top to bottom. Somewhere in the class is a routine which is sucking up that bit stream. At that point, you can capture it without other parsing. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php