refactor mailtool.py

centralize file handling in KeyValueFile class

TODO: be safer about deleting mailboxes, especially cascading deletion
which may be unexpected in some circumstances