发送邮件.py:
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))
import smtplib
from email.mime.text import MIMEText
def email(receiver, title='标题', body='正文'):
******************分割线******************
在同目录下的某py文件下使用:
from 发送邮件 import email
email('1398645374@qq.com','测试邮件','邮件正文正文正文正文正文')

3241

被折叠的 条评论
为什么被折叠?



