refactor server-side email template routes