Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 969911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:43:17+00:00 2026-05-16T02:43:17+00:00

Neither poplib or imaplib seem to offer proxy support and I couldn’t find much

  • 0

Neither poplib or imaplib seem to offer proxy support and I couldn’t find much info about it despite my google-fu attempts.

I’m using python to fetch emails from various imap/pop enabled servers and need to be able to do it through proxies.

Ideally, I’d like to be able to do it in python directly but using a wrapper (external program/script, OSX based) to force all traffic to go through the proxy might be enough if I can’t find anything better.

Could anyone give me a hand? I can’t imagine I’m the only one who ever needed to fetch emails through a proxy in python…

** EDIT Title edit to remove HTTP, because I shouldn’t type so fast when I’m tired, sorry for that guys **

The proxies I’m planning to use allow socks in addition to http.

Pop or Imap work through http wouldn’t make much sense (stateful vs stateless) but my understanding is that socks would allow me to do what I want.

So far the only way to achieve what I want seems to be dirty hacking of imaplib… would rather avoid it if I can.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:43:18+00:00Added an answer on May 16, 2026 at 2:43 am

    You don’t need to dirtily hack imaplib. You could try using the SocksiPy package, which supports socks4, socks5 and http proxy (connect):

    Something like this, obviously you’d want to handle the setproxy options better, via extra arguments to a custom __init__ method, etc.

    from imaplib import IMAP4, IMAP4_SSL, IMAP4_PORT, IMAP4_SSL_PORT
    from socks import sockssocket, PROXY_TYPE_SOCKS4, PROXY_TYPE_SOCKS5, PROXY_TYPE_HTTP
    
    class SocksIMAP4(IMAP4):
        def open(self,host,port=IMAP4_PORT):
            self.host = host
            self.port = port
            self.sock = sockssocket()
            self.sock.setproxy(PROXY_TYPE_SOCKS5,'socks.example.com')
            self.sock.connect((host,port))
            self.file = self.sock.makefile('rb')
    

    You could do similar with IMAP4_SSL. Just take care to wrap it into an ssl socket

    import ssl
    
    class SocksIMAP4SSL(IMAP4_SSL):
        def open(self, host, port=IMAP4_SSL_PORT):
            self.host = host
            self.port = port
            #actual privoxy default setting, but as said, you may want to parameterize it
            self.sock = create_connection((host, port), PROXY_TYPE_HTTP, "127.0.0.1", 8118)
            self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile)
            self.file = self.sslobj.makefile('rb')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked a couple of coworkers about AnkhSVN and neither one of them was
break line tag is not working in firefox, neither in chrome. When i see
So I need to update a text field. Neither the UPDATE statement or the
What reason is there for C# or java having lambdas? Neither language is based
Suppose I have a database table with two fields, foo and bar. Neither of
Shouldn't this be a pretty straightforward operation? However, I see there's neither a size()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.