error when using poplib to get email

2019-08-25 05:14发布

问题:

I am using poplib to get email from the POP3 server.

But this error occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\lib\site-packages\myutils.py", line 251, in dxDown
    m=poplib.POP3('pop3.126.com')
  File "C:\Python26\lib\poplib.py", line 83, in __init__
    self.sock = socket.create_connection((host, port), timeout)
  File "C:\Python26\lib\socket.py", line 500, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11004] getaddrinfo failed

My laptop is in an local network and using a server(ip 192.168.0.1:8080) as proxy to access internet. The error seems poplib cannot interpret the domain "pop3.126.com". How to solve this problem?Thanks!

回答1:

Your proxy is for http, it doesn't effect the pop3 traffic.

A cursory glance suggests that it's probably not able to resolve the hostname to an IP address.

Can you try one of these:

pop3.126.idns.yeah.net
220.181.15.128

Or paste the output of:

nslookup pop3.126.com