utility function to send email from template