# -*- coding: utf-8 -*-

from email.header import Header
from email.mime.text import MIMEText
import smtplib

def sendmail(subject, content):
    sender = '' # 发件人邮箱
    password = '' # 发件人邮箱密码
    recipients = '' # 收件人邮箱
    host = '' # 发件人邮箱主机

    msg = MIMEText(content, 'plain', 'utf-8')
    msg['From'] = sender
    msg['To'] = recipients
    msg['Subject'] = Header(subject, 'utf-8').encode()

    server = smtplib.SMTP(host, 25)
    server.login(sender, password)
    server.sendmail(sender, [recipients], msg.as_string())
    server.quit()

 

posted on 2016-12-26 11:26  昨、夜星辰  阅读(1838)  评论(0编辑  收藏  举报