working version updated with auto config and auto mail