I found this nifty little class on phpclasses.org. Basically, it logs in to an email server and downloads all email attachments, and saves them as files. That’s basically it, no more, no less.
This was exactly what I needed though. I wanted to run some daily reports in Google AdWords and Google AdSense, to a specific email address, then process those reports on a daily basis to customize my own reports… in a nutshell.
I did make a few updates to this class.
- The $savedirpath variable was not utilized. It simply saved the files in the same location as the script. I had it implement this parameter.
- I added another parameter to delete emails after downloading the attachments. Luckily for me, when I went to add the code, I found it was already there, just commented out.
- I tidied up the code a bit to make it more readable for me.