Pregunta

Cuando uso esta línea:

m = imaplib.IMAP4("some host")

Me sale este error:

 m = imaplib.IMAP4("some host")
  File "C:\Python25\lib\imaplib.py", line 163, in __init__
    self.open(host, port)
  File "C:\Python25\lib\imaplib.py", line 230, in open
    self.sock.connect((host, port))
  File "<string>", line 1, in connect
error: (10061, 'Connection refused')

¿Cómo puedo hacer el tratamiento de errores de este error?

¿Fue útil?

Solución

Use un bloque de try/except estándar:

import socket

try:
    m = imaplib.IMAP4("some host")
except socket.error, e:
    print "Error opening IMAP connection: ", e
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top