PHP or Perl script that runs on any linux system that does the following.
- Checks a certain email address (pop or imap ok)
- Gets the email, strips the attachments out of it, and saves them to
a directory on the server
- File extensions that are allowed as an attachment can be configued in the script. Other extensions are ignored.
- In the script, a root directory for attachments to be saved is specified, and the sub-directory (that is under the hard coded root directory) is specified in the subject of the mail.
Example, if the root directory is hard coded as "/home/me/attachments" and someone sends a mail to the specified email address with an attachment, and the Subject of the mail is "mystuff-docs", then the attachment would be stripped and placed in the /home/me/attachments/mystuff/docs/ directory.
- If the directory that is specified in the Subject of the mail doesnt exist, it should be created, with any other directories in the path specified in the Subject (the whole path should be created if it doesnt exist.
- The body of the mail should be stored in another fixed (configured) directory, with the timestamp of the mail.
- A log of any errors should be stored in another directory that is also configured.
Preferable, this solution should be standalone (not need any other files other than standard PHP libs or perl libs, but if that is impossible, procmail and fetchmail may be used for mail fetching and processing.