手机看片精品高清国产日韩,色先锋资源综合网,国产哺乳奶水91在线播放,乱伦小说亚洲色图欧洲电影

幫助中心 >  技術知識庫 >  數據庫 >  相關技術支持 >  Python利用QQ郵箱發送郵件的實現方法(

Python利用QQ郵箱發送郵件的實現方法(

2017-07-03 08:17:23 16317

Python2.7

#!/usr/bin/env python2.7
# -*- coding=utf-8 -*-
import smtplib
from email.mime.text import MIMEText
_user = "648613081@qq.com"
_pwd = "這里改成你的授權碼"
_to  = "648613081@qq.com"
msg = MIMEText("this is a email from python,ha ha ha ...")
msg["Subject"] = "這里是主題"
msg["From"] = _user
msg["To"] = _to
try:
  s = smtplib.SMTP_SSL("smtp.qq.com", 465)
  s.login(_user, _pwd)
  s.sendmail(_user, _to, msg.as_string())
  s.quit()
  print "發送成功"
except s.smtplib.SMTPException, e:
  print "發送失敗"

Python3.6

#!/usr/bin/env python3.6
# -*- coding=utf-8 -*-
import smtplib
from email.mime.text import MIMEText
_user = "648613081@qq.com"
_pwd = "這里改成你的授權碼"
_to  = "648613081@qq.com"
msg = MIMEText("this is a email from python,ha ha ha ...")
msg["Subject"] = "這里是主題"
msg["From"] = _user
msg["To"] = _to
try:
  s = smtplib.SMTP_SSL("smtp.qq.com", 465)
  s.login(_user, _pwd)
  s.sendmail(_user, _to, msg.as_string())
  s.quit()
  print ("發送成功")
except (s.smtplib.SMTPException, e):
  print ("發送失敗")


提交成功!非常感謝您的反饋,我們會繼續努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務,我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: