python QQ邮件发送
生活随笔
收集整理的這篇文章主要介紹了
python QQ邮件发送
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
郵箱授權碼
- 什么是授權碼????????
https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256
- 進入QQ郵箱》設置》賬戶 往下找 (POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服務)
- 開啟?POP3/SMTP服務??
- 獲得16位授權碼
- python 發郵件
- import smtplib from email.mime.text import MIMEText from email.header import Headermsg_from = '1111111@qq.com' # 發送方郵箱 passwd = 'qwqwqwqwqwqwqwqwqw' # 填入發送方郵箱的授權碼 msg_to = '222222@qq.com' # 收件人郵箱 subject = "python郵件測試" # 主題#內容 mail_msg = """ <p>Python 郵件發送測試...</p> <p><a href="http://www.baidu.com">百度一下</a></p> """ msg = MIMEText(mail_msg, 'html', 'utf-8') msg['Subject'] = Header(subject, 'utf-8') msg['From'] = msg_from msg['To'] = msg_totry:s = smtplib.SMTP_SSL("smtp.qq.com", 465) # 郵件服務器及端口號s.login(msg_from, passwd)s.sendmail(msg_from, msg_to, msg.as_string())print("發送成功") finally:s.quit()
?
?
總結
以上是生活随笔為你收集整理的python QQ邮件发送的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: XSL和XSLT
- 下一篇: websocket python爬虫_p