當前位置:首頁 » 編程語言 » python郵箱驗證

python郵箱驗證

發布時間: 2023-09-26 01:35:13

python smtp郵件發送失敗怎麼辦

以下代碼調試通過:

#coding:utf-8
importsmtplib
fromemail.mime.textimportMIMEText
fromemail.headerimportHeader

sender='[email protected]'
receiver='[email protected]'
subject='pythonemailtest'
smtpserver='smtp.139.com'
username='[email protected]'
password='xxxxxx'

msg=MIMEText('你好','text','utf-8')#中文需參數『utf-8',單位元組字元不需要
msg['Subject']=Header(subject,'utf-8')

smtp=smtplib.SMTP()
smtp.connect('smtp.139.com')
smtp.login(username,password)
smtp.sendmail(sender,receiver,msg.as_string())
smtp.quit()

運行效果:

熱點內容
走心機編程教學 發布:2025-07-01 15:34:30 瀏覽:219
安卓系統哪個bug最少 發布:2025-07-01 15:34:16 瀏覽:777
不是安卓怎麼讓時間顯示在屏幕上 發布:2025-07-01 15:20:54 瀏覽:507
黃岩數控編程培訓 發布:2025-07-01 15:12:30 瀏覽:978
迷宮尋路演算法 發布:2025-07-01 15:12:29 瀏覽:543
微信視頻緩存目錄 發布:2025-07-01 14:58:59 瀏覽:393
vmwarelinux教程 發布:2025-07-01 14:50:33 瀏覽:498
名詞解釋預演算法 發布:2025-07-01 14:34:36 瀏覽:918
iis文件拒絕訪問 發布:2025-07-01 14:34:20 瀏覽:570
蘋果和安卓相比哪個游戲多 發布:2025-07-01 14:24:16 瀏覽:762