import smtplib
import email.mime.multipart
import email.mime.text
def send_email(SMTP_host, from_addr, password, to_addrs, subject='', content=''):
"""
发送邮件
:param SMTP_host: smtp.163.com
:param from_addr: 发送地址:xxx@163.com
:param password: 密码: password
:param to_addrs: 发送给谁的邮箱: xxx@qq.com
:param subject: 邮件主题: test
:param content: 邮件内容: test
:return: None
"""
msg = email.mime.multipart.MIMEMultipart()
msg['from'] = from_addr
msg['to'] = to_addrs
msg['subject'] = subject
content = content
txt = email.mime.text.MIMEText(content)
msg.attach(txt)
smtp = smtplib.SMTP_SSL(SMTP_host)
smtp.login(from_addr, password)
smtp.sendmail(from_addr, to_addrs, str(msg))
smtp.quit()
send_email('smtp.sina.com', 'XXXXXX@sina.com', 'XXXX', '285512405@qq.com', '邮箱测试-桃子', '这是邮件测试的内容')