3

Curious to know if there is a handy solution for showing cool email stats like Ma.tt's contact page http://ma.tt/contact/

Inbox: 157. Low priority: 1,461. Unknown: 155. I’ve sent out 920 emails to 357 people in the past month.

2
  • using some PHP scripts like pchart, or easier - using Google's Chart API. matt uses Google I think Commented Jan 5, 2011 at 23:45
  • @AA The page doesn't even have charts! I am talking about the stats, counts in a variable is fine for me. I can get the charts thing done if I want to.
    – Ashfame
    Commented Jan 6, 2011 at 18:56

2 Answers 2

4

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

1
  • Yeah! I tried the IMAP extension when Rarst answered it but then I didn't have much success possibly because of the large number of emails I have in my gmail inbox. Tried limiting them but still didn't have much success and then left the idea there to be picked up again some time later. IMAP extension was new to me, I can deal with the rest. Thanks for taking the time to answer this :)
    – Ashfame
    Commented Mar 29, 2011 at 13:30
4

As far as I know stats are not really inherent feature of email. In comments under Email Graphs post about this feature Otto says that stats are pulled out of database.

So they are somehow tracked in first place, which has little to do with WordPress. It depends on what you use for your email account and server (if not from some free service).

3
  • I don't think the graphs are still there. I never saw them. I was talking about the stats, like how many unread mails and so. I think the stats are fetched from the mailbox and not by updating values on WordPress side on events (we would still need to fetch the unread mail count). My question was close to like if anyone knows about a script with which we can connect to mailbox and build up those stats. But I think it can be easily done now that I have came across php_imap().
    – Ashfame
    Commented Feb 8, 2011 at 13:28
  • @Ashfame graphs appear when you click those stats. You can use POP/IMAP to gather some basic data, but I don't think it will be accurate for historical display like those graphs.
    – Rarst
    Commented Feb 8, 2011 at 13:34
  • I didn't realise they were links. Nice. Someone else coming up here will get help that we can use something like php_imap() to get those stats and then we can store them in WP and set it to run via cron daily. And then Google Charts API or any other library can be used to display graph!
    – Ashfame
    Commented Feb 8, 2011 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.