views:

98

answers:

2

i am searching for a way to read mail messages from a PHP application, including access to attachments etc. imap functions are not acceptable as a solution, as this application will handle mails with heavy attachments.

i have full access to the server's mail folder from php via filesystem. any thoughts?

A: 

I had a question like this a while back. See if any of the answers help you: http://stackoverflow.com/questions/114953/how-to-get-email-and-their-attachments-from-php

postfix + maildrop was the solution I ended up taking, It routes the emails through to a PHP script when it arrives and in my case, the PHP does something with the attachment. But I only needed to read each email once. If you need to be able to browse all the emails, you either need to store the results of maildrop or find another solution.

If you need to full access to all emails, POP and IMAP are popular choices because they do work. I'm not sure why you're against them.

Oli
i'm against the, as you say, since they are both **protocols** which means traffic. that hardly seems fine when the web server and the mail server are on the same filesystem, it would just be wasteful, in my mind. correct me if i'm wrong.
Nir Gavish
also, after some checking, host does not appear to be running postfix or maildrop, but i can't really be sure.
Nir Gavish
You're not wrong but going through abstraction layers like IMAP means you get to deal with your mail in a much saner way, saving you development time. maildrop will get you "bare-metal" access but only for new incoming email.
Oli
well, all i need is incoming mail, the mailbox will only be checked by the app, never by a human. as for saving development time, i'm all for it, and i'm as lazy as the next programmer (the good lazy, i mean :) ), believe me - but this app needs the efficiency more than it needs the short development cycle.
Nir Gavish
+1  A: 

I think you could use a combo of the Pear packages Mail_Mbox and Mail_mimeDecode. Use Mail_Mbox to read new mail from the inbox, one message at a time, and use Mail_mimeDecode to extract the attachements. All this will be done w/o IMAP. You can then save the read messages to a different mbox to keep the inbox clean.

Pear - Mail_Mbox
Pear - Mail_MimeDecode

Jay
thanks, that's a great pointer. one question though, how do i know my mailboxes are indeed Unix MBOXes?
Nir Gavish
Hey Nir, just saw this. The only way is to get onto the server and see how your mail's being stored (or ask the admin). If it's being delivered to a local account on the box, it'll be either a mail dir, or an mbox. If it's being stored in an account accessible via IMAP, it could be in a variety of formats, and the web server may not have permission to modify it. Best thing you can do is ask the server admin how it's being stored.
Jay