I found this niftly 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.

  1. The $savedirpath variable was not utilized. It simply saved the files in the same location as the script. I had it implement this parameter.
  2. 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.
  3. Tidied up the code a bit to make it more readable for me.

You can download the original files here and get my updates here.