當前位置:首頁 » 編程語言 » 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返回this 發布:2025-10-20 08:28:16 瀏覽:534
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:821
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:524
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:707
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:627
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:939
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:196
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:56
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:749
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:652