1. Updated the order of things a little bit to improve speed on the front of the script
2. In doing the above, some SQL queries where moved into an 'if' at the bottom of the
script that will only be run if needed
3. The SMTP server and port are pulled from the database
4. The insert query to log checks is now also inserting a date and time