Added smtp_host variable instead of static smtp configuration
Removed duplicate code
Replaced time library with datetime library