Exported the email-sending function so I can use it as a library in the main part of the app. Also added logic so that I can continue to use it from the command line for development.