Remove unused import
Extract the template factory to its own file

It's going to be used for more than just the Mailer.