import os
import smtplib10年專注建站、設(shè)計、互聯(lián)網(wǎng)產(chǎn)品定制開發(fā)服務(wù),業(yè)務(wù)涵蓋成都品牌網(wǎng)站建設(shè)、商城開發(fā)、小程序設(shè)計、軟件系統(tǒng)開發(fā)、成都app開發(fā)等。憑借多年豐富的經(jīng)驗,我們會仔細(xì)了解每個客戶的需求而做出多方面的分析、設(shè)計、整合,為客戶設(shè)計出具風(fēng)格及創(chuàng)意性的商業(yè)解決方案,創(chuàng)新互聯(lián)公司更提供一系列網(wǎng)站制作和網(wǎng)站推廣的服務(wù),以推動各中小企業(yè)全面信息數(shù)字化,并利用創(chuàng)新技術(shù)幫助各行業(yè)提升企業(yè)形象和運營效率。
from email.mime.text import MIMEText
def send_mail(receiver):
mail_server = 'smtp.163.com' sender_useranme = os.getenv('MAIL_USERNAME') sender_password = os.getenv('MAIL_PASSWORD') content = '<a href="www.baidu.com">點擊完成驗證</a>' message = MIMEText(content, 'html') message['Subject'] = '用戶激活' message['From'] = sender_useranme mail = smtplib.SMTP(mail_server) mail.login(sender_useranme, sender_password) mail.sendmail(sender_useranme, receiver, message) mail.quit()
bug : TypeError: expected string or bytes-like object
需要將message對象格式化字符串就OK了
mail.sendmail(sender_useranme, receiver, message.as_string())
有時候
分享名稱:smtplib,發(fā)送郵件時的bug
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計、服務(wù)器托管、域名注冊、網(wǎng)頁設(shè)計公司、關(guān)鍵詞優(yōu)化、手機(jī)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源:
創(chuàng)新互聯(lián)
分享網(wǎng)址:http://aaarwkj.com/article40/pcopho.html