Auto-forward mail message template written in Python

Source: Internet
Author: User

#-*-Coding:utf-8-*-#加密东西def Decrypt (key, s): c = ByteArray (str (s). Encode ("GBK")) n = Len (c) if n% 2! = 0:        Return "" n = n//2 B = ByteArray (n) j = 0 for I in range (0, n): C1 = c[j] C2 = c[j + 1] j = j + 2 C1 = c1-65 C2 = c2-65 B2 = C2 * + C1 B1 = b2 ^ key B[i] = B1 t Ry:return B.decode ("GBK") Except:return "Failed" def SendMail (port): Import pandas as PD import da Tetime Import Smtplib date=str (Datetime.datetime.now ()) [: ten] from Email.mime.text import Mimetext from email.h Eader Import Header from email.mime.application import mimeapplication from email.utils import formataddr from em Ail.mime.multipart Import Mimemultipart try:data=pd.read_csv ("/home/deploy/wangliang/file/000000_0", delimiter= ' \ t ', names=[' date ', ' City ', ' Total number ', ' 3-7 days ', ' 3-7 days ', ' 7-15 days ', ' 7-15 days ', ' 15-30 days ', ' 15-30 days ', ' 30 days ', ' 30 days ' or more ', ' data.to_csv home/deploy/wangliang/file/Idle Data"+date+". csv ", Index=none) Except:pass message=mimemultipart () mail_host =" Smtp.exmail.qq.com "Mail_us ER = "" #账号 Mail_pass = "" #密码 sender = ' #发送人 receivers = [] #接收人列表 # xlsxpart=mimeapplication (Open (U/home/de ploy/wangliang/file/Idle Data "+date+". csv ", ' RB '). Read (). Decode (' Utf-8 '). Encode (' GBK ')) # Xlsxpart.add_header (' Content-disposition ', ' attachment ', filename= "Xianzhi" +date+ ". csv") # Message.attach (xlsxpart) Add Attachment message[' from ' = Formataddr (["Sender nickname", ' Account ']) message[' to '] = ";". Join (receivers) Subject = ' Subject ' message[' subject '] = Header (subject, ' Utf-8 ') textextpart= mimetext ("<font Colo R=blue>hello:<br> accessories for, thank you </font> ", ' html ', ' Utf-8 ') #文本信息 Message.attach (textextpart) message[" Accept-language "]=" ZH-CN "message[" Accept-charset "]=" iso-8859-1,utf-8 "SMTPBJ = smtplib. Smtp_ssl () # SSL authentication Smtpbj.connect (mail_host,port) #连接 smtpbj.login (Mail_user, Mail_pass) smtpbj.sendmail (sender, R Eceivers, Message.as_strING ()) if __name__== ' __main__ ': SendMail (port=465) 

Auto-forward mail message template written in Python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.