當前位置:首頁 » 編程語言 » 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-02 00:12:28 瀏覽:345
shell腳本需要編譯鏈接 發布:2025-07-02 00:04:20 瀏覽:474
微信如何重設密碼 發布:2025-07-02 00:02:27 瀏覽:545
java代碼基礎 發布:2025-07-02 00:00:46 瀏覽:304
煙花的代碼c語言 發布:2025-07-01 23:56:04 瀏覽:224
安卓默認打開文件方式怎麼修改 發布:2025-07-01 23:30:38 瀏覽:862
壓縮機接線座 發布:2025-07-01 23:17:48 瀏覽:662
iqoo瀏覽器緩存路徑 發布:2025-07-01 23:12:38 瀏覽:693
明日之後如何獲得最新伺服器 發布:2025-07-01 23:12:35 瀏覽:52
tv加密頻道 發布:2025-07-01 23:10:58 瀏覽:625