Added function to send email and logging to file is now optional