The update to nodemailer requires different initialization.

Do a refactor while I am at it to clean up the code.

fixes #4000
Merge pull request #4001 from shane-tomlinson/issue-4000-email-sending

The update to nodemailer requires different initialization.