473,769 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

poplib - retr() getting stuck

Hi,

I am using poplib's retr() to fetch mails from my gmail account. It
works fine, in some cases it gets stuck inside the retr() method and
does not come out.

From the logs I could find that when retr() is called, it stops
executing further statements, nor does it throw an exceptions but
simply stops. My code is roughly like the foll:

try:
print "1"
mymsg = M.retr(msg_no)
print "2"
except poplib.error_pr oto, e:
print "exception1 "
except Exception, e:
print "exception2 "

What can be the reason for this? Can anyone help me.

Thanks
Roopesh
Jun 27 '08 #1
2 2651
En Fri, 20 Jun 2008 04:37:32 -0300, Roopesh <ro*********@gm ail.com>
escribió:
I am using poplib's retr() to fetch mails from my gmail account. It
works fine, in some cases it gets stuck inside the retr() method and
does not come out.
Probably the server stopped responding. By default, sockets have no
timeout value set - that is, a recv() call may block forever.
Try using socket.setdefau lttimeout
<http://docs.python.org/lib/module-socket.htmlbefo re creating the
connection, or search this group for past responses to this same problem.

--
Gabriel Genellina

Jun 27 '08 #2
Thanks for the help.

At present I have modified the poplib code as follows (In POP3 and
POP3_SSL classes): Is it the correct way?

def __init__(self, host, port = POP3_PORT):
self.host = host
self.port = port
msg = "getaddrinf o returns an empty list"
self.sock = None

socket.setdefau lttimeout(30)

for res in socket.getaddri nfo(self.host, self.port, 0,
socket.SOCK_STR EAM):
af, socktype, proto, canonname, sa = res
try:
self.sock = socket.socket(a f, socktype, proto)
self.sock.conne ct(sa)
except socket.error, msg:

Thanks
Roopesh
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3027
by: Rybread | last post by:
Real quick, I have account X and I want a python script that goes in and looks for emails sent from Y and then to save them. i'm trying to go off the swen killer I have listed below (which i took from someone on this NG): import poplib import time print 'Start at', time.asctime()
2
6734
by: brettk | last post by:
Hello All, Here's what I'm trying to do: I need to connect to a pop3 server, download all messages, and copy all of the attachments into a specific directory. The actual email message is unimportant. Now, I've found plenty of examples that strip the attachments from an email message, but most (if not all) of them take a file parameter. My question is this:
2
2698
by: Steve Greenland | last post by:
For the poplib.POP3 object, docs say: list() Request message list, result is in the form (response, ). If which is set, it is the message to list. But (I've folded the long line): Python 2.3.5 (#2, May 4 2005, 08:51:39) on linux2
0
1226
by: Frank Churchill | last post by:
Has anyone used poplib and popfile together? I've tried everything I can think of to specify SRVR in poplib: "127.0.0.1:8081" "127.0.0.1,port=8081" "localhost:8081" "localhost,port=8081" and probably a few other things, but poplib can't see
4
2197
by: SuperHik | last post by:
Hi! I want to connect to gmail but... It requires SSL so I worte: Traceback (most recent call last): File "<interactive input>", line 1, in ? File "C:\Python24\lib\poplib.py", line 359, in __init__ self.sslobj = socket.ssl(self.sock, self.keyfile, self.certfile) AttributeError: 'module' object has no attribute 'ssl'
3
6100
by: EuGeNe Van den Bulke | last post by:
Hi there, I am trying to use the poplib library to get emails using the retr method. The small program bellow works but the message aren't flagged as read which puzzles me. I believe the pop server is qmail 1.0.6 / vpopmail 5.2.1 and I am running the following script on Windows using Pyhton 2.5. import poplib import email
1
2265
by: erikcw | last post by:
Hi, I keep getting this error from poplib: (error_proto(-ERR EOF) line 121 poplib.py Does this mean the connection has timed out? What can I do to deal with it? Thanks! Erik
4
4768
by: Jean-Claude Neveu | last post by:
Hello, I am writing a Python program to check email using POP3. I've tried the sample code from python.org, and it works great. In other words, the code below successfully prints out my emails. import getpass, poplib, email M = poplib.POP3('mail.blah.com') M.user('username') M.pass_('password')
2
3028
by: SteveC | last post by:
Hello, I am trying to use POP3_SSL class of the poplib module to read email from my gmail account. I can connect just fine using the example here http://www.python.org/doc/lib/pop3-example.html import getpass, poplib M = poplib.POP3('localhost') M.user(getpass.getuser())
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.