Logging and mail sender added to script