首頁  >  文章  >  後端開發  >  python收發郵件

python收發郵件

巴扎黑
巴扎黑原創
2016-11-26 11:26:061573瀏覽

#coding: utf-8  
import smtplib  
from email.mime.text import MIMEText  
from email.header import Header  
 '  
subject = 'python email test2'  
smtpserver = 'smtp.163.com'  
username = '×××'  
password = '×××41 # 授權碼,不是密碼','text','utf-8')#中文需參數'utf-8',單字節字元不需要  
msg['Subject'] = Header(subject, 'utf-8')  
msg[" To"]=receiver 
smtp = smtplib.SMTP()  
smtp.connect('smtp.163.com')  
smtp.login(username, password)  
etp.sendmail(s99.
smtp.quit() 
------------如果passwd不是授權碼的話,報錯如下------------------- 

jack @jack-desktop:~/work/script/test$ python testemai.py 
Traceback (most recent call last): 
  File "testemai.py", line 19, in  
    sm.
  File "/home/jack/anaconda/lib/python2.7/smtplib.py", line 622, in login 
     raise SMTPAuthenticationError(code, resp)  5,57566 月jack@jack-desktop:~/work/script/test$ python testemai.py 
Traceback (most recent call last): 
  File "testemai.py", line 19, in )  
  File "/home/jack/anaconda/lib/python2.7/smtplib.py", line 622, in login 
    raise SMTPAuthenticationError(代碼

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn