You are invited to Log in or Register a free Frihost Account!

Processing mail

Not sure if this is best topic for this - but I'm thinking it is because most grunt work will probably done with PHP/Perl.

What is the best way to process a mailbox automatically? For example, say I have the address, and I want all emails to this address to be automatically processed. This could involve querying and updating a database and sending/forwarding a response email.

Time-critical-ness is not a huge issue (as long as it wouldn't take hours to respond).

Would a cron job be the best way to go here? And, if so, how is the actual interrogation of the mailbox performed? How do you distinguish between different mailboxes on the same domain/account? Does anyone have any good references at all?

Any help would be really really appreciated! I'd prefer any references in Perl, but I'm pretty good at reading and translating PHP anyhow. Thanks all! Very Happy
If the mailserver is on linux it won't be too hard: in that case most of the time mail is stored in plain text files, one file per mailbox or mailfolder. The inbox is most of the time located in the folder /var/spool/mail, the other boxes are most of the time located in the user home-dir in the mail-folder. (for example: /home/johndoe/mail). With php you can simply copy these files (because if you don't copy them and simply locks them, during the lock there can't be any mail delivered to you), lock them and read what's in them. This info can be processed in the normal way.
I know Python and Perl (maybe PHP, too) have a way to log into an smtp/imap account, and manipulate it from there. But do you want to work directly on the server?
Thanks for the help. I'm basing this on using Frih Server 2, if that gives you any clearer indication.

jabapyth, Using IMAP or POP could actually work out quite well, but since I'm running it directly the script on the same server, would it be easer/more efficient to work directly with the server files? Do you have any experience about which would be the way to go?

johanfh, I found the directory /var/spool/mail/dayveday, but it seems to be empty. Also, I'd want to be able to actually modify the contents of the mailbox (remove emails) - is it ok to lock and then modify the text files? (if I can find them!)

cURL seems to do the job 4 u....
Related topics
Australian state to ban workplace e-mail spying
Yahoo mail is bester
Hotmail accounts at risk
AIM Mail
Web e-mail !
Mail forwarders
PHP Mail Function
PHP: Feedback form issues.. help =P
Where is the Mail cgi located?
Using (yuk) MS Outlook for email? Tired of the spam?
Need help with
Mail with PHP (Simple Tutorial)
Has anyone installed Moodle successfully?
Multiple email Addresses
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.