File_attack记录

GITHUB链接:github source

回顾与记录:

1、多线程。

python多线程是后面在添加socket服务器的时候才用到的。使用的是threading.Thread类继承的办法实现。

使用了生产者和消费者模式。 在这里是使用sys_status作为 产品。 当sys_status为false时,停止生产和消费。整个程序结束。

 

2、多附件的添加:

attach为['file_dir',"file_dir2']

attach应该为已经过滤过的文件目录list

每次添加的文件也不宜过多,过大。

这里是emailclient,只做发送的事,所以过滤都是在传入attach参之前需要解决的问题。

 for f in attach:
    #open with 'rb' to read non-text file
       with open(f,'rb') as f_attach:
           part = MIMEBase('application', 'octet-stream')
           part.set_payload(f_attach.read())
           Encoders.encode_base64(part)
           part.add_header('Content-Disposition',
                            'attachment; filename=""%s"' %os.path.basename(f))
           msg.attach(part)
   try:

       mailServer = smtplib.SMTP("smtp.qq.com")
       mailServer.login(gmail_user, gmail_pwd)
       mailServer.sendmail(gmail_user, to, msg.as_string().encode('utf-8'))
       mailServer.close()
   except KeyboardInterrupt:
       sys.exit()

 

转载于:https://www.cnblogs.com/-Doraemon/p/4818491.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值