template parsing and email sending