Question

I am using python poplib.

Does a POP3 connection timeout after a period of inactivity? Is there a way to set this timeout? Would such a timeout cause emails flagged for deletion to be deleted as if quit() had been called?

The only timeout I see mentioned refers to the connection-attempt timeout

class poplib.POP3(host[, port[, timeout]])

My POP3.quit() call is throwing a poplib.error_proto exception with the message "timed out" and I am wondering if the connection will ever timeout on its own.

Was it helpful?

Solution

Does a POP3 connection timeout after a period of inactivity?

This mostly depends on the server software on the other end. Some socket libraries may let you specify a local timeout. The connection will timeout at whatever time is the shortest between the local and the remote timeout.

Is there a way to set this timeout?

Unless you control the server software settings (e.g. you run your own server), you can't change the remote timeout.

Would such a timeout cause emails flagged for deletion to be deleted as if quit() had been called?

Timeout behavior is usually the same as manually closing the socket (with or without shutdown). If you don't send the quit command, messages won't be deleted from the server.

OTHER TIPS

POP3 is sort of transactional. So if you download and delete a message from the server, it will not be effective until you close the connection gracefully. The POP3.quit() method has an insightful description about it. The magic word is commit.

The connection timeout is usually a server setting and, of course, when the server times out the connection it is considered a rollback.

Yes a POP3 socket will eventually time out. Looking here you pass the timeout in the constructor.

http://docs.python.org/library/poplib.html

class poplib.POP3(host[, port[, timeout]])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top