python模块-发送邮件
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# author:Sun
# make_time:2018/8/2
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
def sendmail_2018():
msg = MIMEText('python', 'plain', 'utf-8') # 邮件内容、类型默认:plain、默认字符集
msg['From'] = formataddr(['python学院', 'xius2222un@163.com']) # 发送方
msg['To'] = formataddr(['python', '3335@qq.com']) # 接收方
msg['Subject'] = 'python开发面试邀请' # 主题
server = smtplib.SMTP('smtp.163.com', 25) # 邮件服务器
server.login('邮箱', '密码') # 登陆
server.sendmail('xxx@163.com', ['222@qq.com', '333@qq.com', ], msg.as_string())
server.quit()
人生苦短,我用python!