I've wanted Mutt to be properly scriptable; it doesn't have much good in the way of configuration. I've been casually puttering around ideas for a long time about writing my own email client that's much more customizable. Maybe use a database backend?
Edit: looking at Sup, maybe it's what I want.