Switch the mailers to be invoked using ids, not model objects. This makes it easier to support asynchronous mail jobs, as only simple ids need to be persisted.

Fixes #2806