Add templating to email sending. close #269, close #270