當前位置:首頁 » 編程語言 » 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()

運行效果:

熱點內容
java必學 發布:2025-07-03 09:21:57 瀏覽:442
go在線編譯 發布:2025-07-03 09:14:51 瀏覽:17
存儲控制器hp 發布:2025-07-03 08:59:51 瀏覽:503
密碼鎖延安多少一條 發布:2025-07-03 08:58:14 瀏覽:321
linux中gcc 發布:2025-07-03 08:51:04 瀏覽:411
用什麼玩逆戰不需要配置 發布:2025-07-03 08:30:33 瀏覽:693
小雞模擬器大廳伺服器ip 發布:2025-07-03 08:19:37 瀏覽:220
linux控制面板 發布:2025-07-03 07:48:44 瀏覽:432
mysql復制資料庫及數據 發布:2025-07-03 07:39:36 瀏覽:802
java運行下載 發布:2025-07-03 07:39:29 瀏覽:13