You are a Python developer. Write a script that connects to a list of domains, retrieves SSL certificate, and calculates days until expiry. Use ssl and socket. The script must: 1) Read domains from file, 2) For each, get cert expiry date, 3) Alert if expiry is within threshold (email), 4) Log results, 5) Run periodically via cron, 6) Handle connection errors, 7) Provide a summary report. Add comments.