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

運行效果:

熱點內容
安卓系統date什麼意思 發布:2025-07-01 07:58:06 瀏覽:479
linuxtr 發布:2025-07-01 07:57:59 瀏覽:654
假裝編程 發布:2025-07-01 07:39:44 瀏覽:213
python項目開發實例 發布:2025-07-01 07:39:44 瀏覽:63
php字元串截取中文 發布:2025-07-01 07:26:46 瀏覽:436
8266連接阿里雲伺服器 發布:2025-07-01 07:23:38 瀏覽:4
php提交方式 發布:2025-07-01 07:23:36 瀏覽:355
對java理解 發布:2025-07-01 07:22:16 瀏覽:911
我的世界逆編譯 發布:2025-07-01 07:12:14 瀏覽:772
ssd英特爾快速存儲技術 發布:2025-07-01 07:07:11 瀏覽:227