I have a very simple program to send mails that uses pythons smtplib
to send mails via a secure socket. For some reason the socket creation takes around 80 seconds. This is the code I use:
with smtplib.SMTP_SSL(config['SMTP_HOST'], config['SMTP_PORT']) as server:
# Send mail here
After the socket has been created everything runs smooth and fast. A temporary "fix" for the problem is to pass a small timeout, like so:
with smtplib.SMTP_SSL(config['SMTP_HOST'],config['SMTP_PORT'], timeout=0.5) as server:
# Send mail here
Now the socket creation takes 0.5 seconds.
Anyone knows why this can happen? I use python 3.9. I tested it in python 3.7 but had the same problems. The exact same script runs instantly on other computers, so maybe it's not python related? I run macOS Big Sur 11.0.1.
Whatever the problem was, it has been fixed with the latest Mac OS Update.