send_mail.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:base_function 作者: Rockyzsu 项目源码 文件源码
def send_txt(self, filename):
        # ????????????????????????????????????
        self.smtp = smtplib.SMTP_SSL(port=465)
        self.smtp.connect(self.server)
        self.smtp.login(self.username, self.password)
        #self.msg = MIMEMultipart()
        self.msg = MIMEText("content", 'plain', 'utf-8')
        self.msg['to'] = self.to_mail
        self.msg['from'] = self.from_mail
        self.msg['Subject'] = "459"
        self.filename = filename + ".txt"
        self.msg['Date'] = Utils.formatdate(localtime=1)
        content = open(self.filename.decode('utf-8'), 'rb').read()
        # print content
        #self.att = MIMEText(content, 'base64', 'utf-8')
        #self.att['Content-Type'] = 'application/octet-stream'
        # self.att["Content-Disposition"] = "attachment;filename=\"%s\"" %(self.filename.encode('gb2312'))
        #self.att["Content-Disposition"] = "attachment;filename=\"%s\"" % Header(self.filename, 'gb2312')
        # print self.att["Content-Disposition"]
        #self.msg.attach(self.att)

        #self.smtp.sendmail(self.msg['from'], self.msg['to'], self.msg.as_string())
        self.smtp.sendmail(self.msg['from'], self.msg['to'], self.msg.as_string())
        self.smtp.quit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号