more generic way to send email with templates