I have tried to attached a file to the mail using python. Code:
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIME
There seems to be a bug in urllib3 version 1.25.9 package. This produced "socket.gaierror: [Errno 11001] getaddrinfo failed" error for me (working from behind an authenticated proxy server). Downgrading to urllib3 version 1.25.8 solved the problem.
The below answer may be quite irrelevant to the question. But,some users may have a different scenario.
If a server can be reached only through VPN and if we try to reach it with VPN disconnected, this error : "gaierror: [Errno 11001] getaddrinfo failed" crops up.
Connect to VPN and then executing the code should work good.