begin full rewrite of mail plugin