How to make smtplib work over SOCKS5 proxy?

101 Views Asked by At

I am writing an SMTP client and I want to build proxy server support into it. How to make smtplib work through socks5 proxy?

I had the idea to use the SocksiPy module because it was recommended to the user in another question. But this method is used for a proxy with a login without a password (And my proxy requires authorization with a login and password), and this method is very old (the answer was in 2014), there were no new releases of SocksiPy after 2014.

UPD: I tried typing login:password@ip in the socks request:

>>> import socks, smtplib
>>> socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, 'login:password@ip', port)
>>> socks.wrapmodule(smtplib)
>>> r = smtplib.SMTP('smtp.rambler.ru', 587)

And got an error: socks.ProxyConnectionError: Error connecting to SOCKS5 proxy login:password@ip:port: [Errno 11003] getaddrinfo failed

0

There are 0 best solutions below