How can I cron moving mail between folders?


This seemed simple to me at first, but our shell accounts and our email accounts do not seem related to each other on dreamhost.

All I want to do is have a script somewhere that does this:
daily: move all mail from inbox.tomorrow to inbox
weekly: move all mail from inbox.next_week to inbox
monthly: move all mail from inbox.next_month to inbox

The problem is that the shell account where you can edit the crontab is unrelated to the email account with the mail folders.

Any ideas?


A shell account may have its own email address if you set it up that way. A mail-only account has no shell access, so you will be unable to use cron to manipulate its mail.

The other alternative would be some clever scripting from a shell account that does all of this via IMAP. Or you could delete the mail-only account and then add a shell account with the desired email address.



Oh, interesting… so you mean if I set up the shell account first and then use that as an email account, the email WILL be stored under the shell account? It never occurred to me to try it that way.

I also thought of another much more generic method… a script that acts like an imap client which you call from a crontab. It would be able to log into any regular imap server and executes imap commands to move the messages from one folder to another as if it were just another imap client. This solution should then work for any imap server anywhere.

Does anyone know if something like that exists out there?