I am in a situation where i need to work with email attachments automatically, an xml file with various data is being sent to an email address wherein i need to process the data and stick it into a DB.
I had planned to write a script and have a cronjob set up which takes the data cleans it up and then inserts into the DB. This in itself is fine however i can’t think of the best way to get the attached files ready for cronjob to deal with.
Hope that makes sense, any ideas?
For anyone who is in the same situation as above i done it using a combination of php and cron.
Specifically making use of the PHP imap classes.
http://php.net/manual/en/function.imap-open.php
I came across a pre made script ( http://www.nerdydork.com/download-pop3imap-email-attachments-with-php.html ) on the web which with a few tweaks and changes suited my purposes. Have one script use the imap classes to download the xml file, appended to the file name so that we don’t end up overwriting files.
Then use a second script to then read the data from the downloaded files and stick them into the DB.
Works a treat! ^_^