Skip to content

Instantly share code, notes, and snippets.

@ak64th
Last active November 28, 2019 05:53
Show Gist options
  • Save ak64th/683770a64eface0ccdbd6da8759d16cb to your computer and use it in GitHub Desktop.
Save ak64th/683770a64eface0ccdbd6da8759d16cb to your computer and use it in GitHub Desktop.
Use imaplib with socks proxy
# install PySocks first: pip install PySocks
import socket
import socks
import imaplib
socks.set_default_proxy(socks.SOCKS5, "localhost")
socket.socket = socks.socksocket
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login('ak64th@gmail.com','google_app_password')
# ('OK', [b'ak64th@gmail.com authenticated (Success)'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment