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 7806173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:26:56+00:00 2026-06-02T02:26:56+00:00

I am writing some code that uses poplib and imaplib to collect emails through

  • 0

I am writing some code that uses poplib and imaplib to collect emails through a proxy server.

I use the following to set up a proxy connection:-

import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4,proxy_ip,port,True)
socket.socket = socks.socksocket

Which I got from the stackoverflow post:-

http://stackoverflow.com/questions/3386724/python-how-can-i-fetch-emails-via-pop-or-imap-through-a-proxy

Then I make my connection with the email server:-

server = poplib.POP3(self.host, self.port)
server.user(self.username)
server.pass_(self.password)

I am testing my code in a unittest and have encountered a problem that I believe relates to my connection with the proxy not closing down properly.

An example is:-

I have set up the proxy connection and am trying to establish a connection with the email server. As part of the unittest I intentionally use an incorrect email server password.
The poplib library throws an exception that it can’t connect. I catch the exception in the unittest, then move on to the next unittest, trusting the poplib library would properly close my previous connection.

My understanding is that this is not a good thing and that I should be ensuring the email and proxy server connections are properly closed.

I know how to close the pop3 connection:-

server.quit()

But do not know how to close the connection with the proxy server or if I have to do so.

Could someone please help me with this question or with my understanding if that’s where the problem lies 🙂

  • 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-06-02T02:26:58+00:00Added an answer on June 2, 2026 at 2:26 am

    No special action is required. When you close the POP connection, the proxy connection will close automatically, since it’s only needed while you are connected to something through the proxy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some code that uses a class to interact with a matchmaking server
I'm writing some code that uses some unmanaged calls into user32 functions such as
I'm writing some python code to interact with a C DLL that uses structures
I'm writing some code on a mobile device that uses a REST service to
I'm writing some library code, and classes that use that code are required to
I am writing some code in VB.NET that uses a switch statement but in
I'm writing some code that uses dynamic shared libraries as plugins. My command line
I am writing some JavaScript code that uses a string rendered with PHP. How
I've been writing WinForms code that uses a BackgroundWorker to do some async work,
I'm writing Cocoa code that uses some classes defined in a C++ library. I

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.