Ich habe Code im Internet über imaplib und Konfiguration mit meinen Informationen gefunden Ich habe es funktioniert ohne Probleme mit meinem Google Mail-Konto (aber ich musste einige Google Mail-Konfiguration ändern, um es zu tun).Python 3.5 imaplib E-Mails
Ich versuche, den gleichen Code mit meinem azur E-Mail-Service, aber ich jedes Mal den gleichen Fehler:
> Traceback (most recent call last): File "C:\Users\Carlo\Desktop\try.py", line 66, in <module>
> M = imaplib.IMAP4_SSL('mail.example.com') File "C:\Python34-32\lib\imaplib.py", line 1221, in __init__
> IMAP4.__init__(self, host, port) File "C:\Python34-32\lib\imaplib.py", line 181, in __init__
> self.open(host, port) File "C:\Python34-32\lib\imaplib.py", line 1234, in open
> IMAP4.open(self, host, port) File "C:\Python34-32\lib\imaplib.py", line 257, in open
> self.sock = self._create_socket() File "C:\Python34-32\lib\imaplib.py", line 1224, in _create_socket
> sock = IMAP4._create_socket(self) File "C:\Python34-32\lib\imaplib.py", line 247, in _create_socket
> return socket.create_connection((self.host, self.port)) File "C:\Python34-32\lib\socket.py", line 494, in create_connection
> for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "C:\Python34-32\lib\socket.py", line 533, in getaddrinfo
> for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 11004] getaddrinfo failed
Das Problem ist, dass ich kann nicht verstehen, warum ich auch nicht wissen nicht, in was konzentrieren um mein Problem zu lösen ...
Könnten Sie mir bitte helfen?
Dies ist mein Code:
import sys
import imaplib
import getpass
import email
import email.header
import datetime
def process_mailbox(M):
rv, data = M.search(None, '(UNSEEN)')#select just un-read documents
if rv != 'OK':
print("No messages found!")
return
for num in data[0].split():
rv, data = M.fetch(num, '(RFC822)')
if rv != 'OK':
print("ERROR getting message", num)
return
msg = email.message_from_bytes(data[0][1])
print (msg)
hdr = email.header.make_header(email.header.decode_header(msg['Subject']))
subject = str(hdr)
print('Message %s: %s' % (num, subject))
print('Raw Date:', msg['Date'])
# Now convert to local date-time
date_tuple = email.utils.parsedate_tz(msg['Date'])
if date_tuple:
local_date = datetime.datetime.fromtimestamp(
email.utils.mktime_tz(date_tuple))
print ("Local Date:", \
local_date.strftime("%a, %d %b %Y %H:%M:%S"))
M = imaplib.IMAP4_SSL('IMAP')#imap of my azure service
try:
rv, data = M.login("email", "password")#my username and password except imaplib.IMAP4.error:
print ("LOGIN FAILED!!! ")
sys.exit(1)
rv, data = M.select("Inbox") #select data from inbox folder if rv == 'OK':
print("Processing mailbox...\n")
process_mailbox(M)
M.close() else:
print("ERROR: Unable to open mailbox ", rv)
M.logout()
NEUE INFORMATIONEN:
Jungs, die ich so viel Hilfe nicht erhalten haben, so weit, so war ich Dokumentation readying und versuchen, von mir selbst, ich versuche mit IP Adresse der Maschine und mit IMAP die Angabe des Ports und ich habe einen anderen Fehler diesmal ..... Dies ist der Code, den ich bearbeiten:
M = imaplib.IMAP4_SSL('IMAP or IP Address','143')
try:
rv, data = M.login(EMAIL_ACCOUNT, passwd)
except imaplib.IMAP4.error:
print ("LOGIN FAILED!!! ")
sys.exit(1)
Dieses Mal ist der Fehler dieses:
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Einige Hilfe bitte !!?!?!?
SSL-Server hören Port 993, nicht 143. – Max