PHP script that runs on any linux system that does the following.
- Checks a certain email address (pop and/or imap ok, but it must work with gmail accounts, see google help pages on ports and ssl connections)
- 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 configured in the script. Other extensions are ignored.
- In the script, a root directory, and a directory in that root directory for attachments to be saved is specified in a configuration file, and the sub-directory will be specified in the subject of the mail.
Example, if the attachments directory is configured as "/home/me/m2fs/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.
- If the mail subject has spaces or any special characters other than - or _ in it, then those characters should be replaced with "_".
- A log of any errors should be stored in another directory under the root dir that is also configured in the config file.
- zip files should be extracted (not left as zip files) and the contents of the zip file should be saved with their original file names in the directory that is specified in the subject of the email. There is no need to create another directory for the zip file content, just treat those contents as if they were attached to the email unzipped.
- If a file of the same name exists already in the same directory that is specified, then a "_n" (where n is a number starting at one) should be added to the new file before the extension. Eg: if [url removed, login to view] exists, and [url removed, login to view] is sent by email to the same directory, then it should be renamed [url removed, login to view] and saved. If it is sent yet again after that, it should become [url removed, login to view] and so on.
- Each saved email (body file, text without attachments) will be saved.
- The file body (text file) however should be saved in another directory, with the timestamp as the file name e.g. [url removed, login to view] (timestamp until second). The full text should remain in the body file, but not the attachment content. The attachment names however should remain in the content, as this will facilitate searching who sent which attachment later on.
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.
Best is a php script that can be run from php-cli by cron. Otherwise a perl script that can be run by cron is ok. Anyone who proposes php will be chosen over people who chose perl.
12 freelancers estão ofertando em média $166 para este trabalho
Dear Project Owner, I can create this script, all in php+shell scripting. on further communication if you like, i will send you a development plan about steps and time required. Thank you