Template based email sending with SMTP connection management