With the help of the socks module, I can send an email through the socks4 / 5 server:

socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, 'ip', port) socks.wrapmodule(smtplib) s = smtplib.SMTP_SSL("smtp.mail.ru:465") s.login("log", "pass") 

How to send mail via http / s proxy?

    1 answer 1

    The short answer is no way.

    A little wider.

    Socks works at the 4th level of the OSI model and passes traffic as is. The HTTP proxy works at the 7th level and is only responsible for the HTTP protocol. The SMTP protocol also belongs to the 7th level and, accordingly, has its own set of software and libraries for work.

    The only option that I see is to use the API (as in Google )

    • You are wrong, you can send binary data through HTTP proxy, which means you can use it for any protocol that runs over TCP. - Zergatul
    • @Zergatul indisputably I may be wrong. But let's get closer to the body. You have a standard smtp library of the "standard" language (python, java, php, C #, etc). How to use this library to communicate through a normal http proxy with a remote smtp server? Can you give a sample code? I was interested in this issue for a long time. I did not see the solution. Click on the idea or show a solution - I will thank you so much! :] - de_frag
    • It depends on how the library is structured and whether it supports the extension in terms of redefining the socket. Usually this is not. I wrote my class to work with smtp, which supports connection through a proxy, including http: ru.stackoverflow.com/questions/771073/… - Zergatul
    • @Zergatul oh, thanks! I'll play with her. - de_frag pm