The HTTP proxy server may not be supported by PySocks (must be a CONNECT tunnel proxy)

1.6k Views Asked by At

The main idea is to send email through the proxy server using python smtplib. I had my own HTTP proxy server. There are no brief talks about this in any community

What I'm tried is:

import socks
import smtplib

// Assume that below proxy host and port working, checked with request module
proxy_username = 'XXXX'
proxy_paas = 'YYYY'
proxy_host = '0.0.0.0'
proxy_port = 4444
socks.set_default_proxy(
        socks.PROXY_TYPE_HTTP,
        proxy_host,
        proxy_port,
        username=proxy_username,
        password=proxy_paas
)
socks.wrap_module(smtplib)
smtp = smtplib.SMTP('smtp.gmail.com', 587)
print(smtp)

Facing Error from PySocks like below:

raise GeneralProxyError("Socket error", error)
socks.GeneralProxyError: Socket error: 403: Forbidden

[*] Note: The HTTP proxy server may not be supported by PySocks (must be a CONNECT tunnel proxy)
0

There are 0 best solutions below