Nedmail and acme Mail are operating on the same mailbox, and nedmail already has a nice language built in. Back when I did that sort of thing, I found it easy to just fire up nedmail in a shell window.
But ultimatly this sort of functionality should be in upas/fs itself, driven by commands written to /mail/fs/ctl.