0
点赞
收藏
分享

微信扫一扫

发送邮件

发送邮件.py:


import smtplib
from email.mime.text import MIMEText

def email(receiver, title='标题', body='正文'):
    host='smtp.qq.com' #smtp.163.com
    port=465    #25
    sender='904477955@qq.com'  #davidcheng@163.com
    pwd='cvabe****yhebeab'  ##QQ是帐户→POP3下用1毛短信生成的授权码,网易是登录码

    msg=MIMEText(body, ' html','utf8')    #正文纯文本是 plain
    msg['subject']=title
    msg['from']=sender
    msg['to']=receiver

    s=smtplib .SMTP_SSL(host, port)  #smtplib .SMTP('smtp.163.com', 25)
    s.login(sender, pwd)
    s.sendmail(sender, receiver, msg.as_string())

    print('The mail %s,to %s,is sended successly.' %(title, receiver))

******************分割线******************

在同目录下的某py文件下使用:

from 发送邮件 import email

email('test@qq.com','测试邮件','邮件正文正文正文正文正文')


举报

相关推荐

0 条评论