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()
運行效果:
熱點內容