2016-12-12 2 views
0

ich unten Schritte folgen E-Mail mit script-- PythonAuthentifizierungsprobleme E-Mail über Python-Skript in Senden

import smtplib 
smtpUser='[email protected]' 
smtpPass='1234' 
toAdd='[email protected]' 
fromAdd=smtpUser 
subject='Python test' 
header='To:' +toAdd+'\n'+'From:'+fromAdd+'\n' +'Subject:'+ subject 
body='From within a python script' 

print(header + '\n'+ body) 
s= smtplib.SMTP('smtp.gmail.com',587) 
s.ehlo() 
s.starttls() 
s.ehlo() 
s.login(smtpUser,smtpPass) 
s.sendmail(fromAdd,toAdd,header +'\n' + body) 
s.quit() 

dann den Fehler msg ist--

Traceback (most recent call last): 
File "C:/Users/129/PycharmProjects/smtp.py", line 34, in <module> 
s.login(smtpUser,smtpPass) 
File "C:\WinPython-64bit-3.4.4.2\python-3.4.4.amd64\lib\smtplib.py", line 652, in login 
raise SMTPAuthenticationError(code, resp) 
smtplib.SMTPAuthenticationError: (501, b'5.5.2 Cannot Decode response q9sm74360527pfg.47 - gsmtp') 
Process finished with exit code 1 

jemand mir bitte erklären, was zu schicken ist der Fehler, wenn ich nicht falsch bin, ist es mit Google-Sicherheit verwandt.

Antwort

0

benutzte ich diese eine E-Mail von einem Google Mail-Konto senden:

s = smtplib.SMTP('smtp.gmail.com:587') 
s.starttls() 
s.login(username, password) 
s.sendmail(from_mail, to_mail, msg.as_string()) 
s.quit() 

here Werfen Sie einen Blick. Es hat für mich funktioniert.

Verwandte Themen