python调用邮件类

class SendEmail:
    global send_user
    global email_host
    global password
    email_host = "smtp.163.com"  # 163服务器
    send_user = "[email protected]"
    password = "xuefei494199078"

    def send_mail(self, user_list, sub, content):  # 收件人,主题,内容
        user = "xuefei" + "<" + send_user + ">"  # 发件人
        message = MIMEText(content, _subtype='plain', _charset='utf-8')  # 邮件的内容
        message['Subject'] = sub  # 主题
        message['From'] = user  # 发件人
        message['To'] = ";".join(user_list)  # 收件人,用;连接
        server = smtplib.SMTP()  # 连接到邮件服务器
        server.connect(email_host)
        server.login(send_user, password)  # 登录到服务器
        server.sendmail(user, user_list, message.as_string())  # 来自谁,发送给谁,发送什么
        server.close()  # 关掉连接

    def send_main(self, pass_list, fail_list):  # 通过/不通过率
        pass_num = float(len(pass_list))
        fail_num = float(len(fail_list))
        count_num = pass_num + fail_num
        # 统计成百分比
        pass_resul

你可能感兴趣的:(python)