Expand email-API to support testing.
Revert "Expand email-API to support testing."

This reverts commit fe2d35ba149d07bba3b9362bff3a6a44a4fd0dd9.
Add support for email-testing.
Propagate values from UI to mailer.
Properly define all global variables.