3

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?

Nir Gavish
  • 1,034
  • 3
  • 13
  • 28
  • "as this application will handle mails with heavy attachments." To me, right there is your problem. Email is not made for large file transfers, even if it can be wrangled to do it. Why not look at a different way of getting the files to the server? – micmcg Feb 16 '10 at 01:10
  • well, it's more or less a project requirement - to 'wrangle' mail in this manner, so that is my baseline, no way around it. – Nir Gavish Feb 16 '10 at 22:50

2 Answers2

1

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
  • 2,123
  • 1
  • 22
  • 29
  • thanks, that's a great pointer. one question though, how do i know my mailboxes are indeed Unix MBOXes? – Nir Gavish Feb 16 '10 at 22:51
  • 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 Mar 02 '10 at 21:34
0

I had a question like this a while back. See if any of the answers help you: 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.

Community
  • 1
  • 1
Oli
  • 235,628
  • 64
  • 220
  • 299
  • 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 Feb 15 '10 at 17:43
  • also, after some checking, host does not appear to be running postfix or maildrop, but i can't really be sure. – Nir Gavish Feb 15 '10 at 18:12
  • 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 Feb 15 '10 at 18:14
  • 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 Feb 15 '10 at 18:45