copied over mailer stuff from TYML