Email stats at Ma.tt contact form

This is actually not all that hard to do using the imap functions in PHP: http://php.net/manual/en/book.imap.php

Basically, he has some script somewhere which runs every hour or so. I have not seen this script, but I can venture a good guess about how it works.

First, it connects to his email system, probably using imap.

Second, it performs some set of custom rules to divide new emails into high and low priorities in some manner. This much is obvious from the contact page.

Third, it gets the counts and stores them in a database table custom made for storing this count.

To display the graphs, I wrote some queries in a Page Template that connects to that custom table, gets the counts for the last month, does a bunch of math and reformatting of the numbers, and finally produces a URL to the Google Chart API with the numbers to display the graph.

A very minimal knowledge of PHP and a server with the php_imap extension is all that’s really required to script your own email. This is a highly instructive read if you’ve never taken a look at it before:

http://php.net/manual/en/book.imap.php

Leave a Comment