zoukankan      html  css  js  c++  java
  • python mail smtplib

    #!/usr/bin/env python
    # _*_ coding: utf-8 _*_
    # @Time     : 2017/11/1 15:13
    # @Author   : otfsenter
    # @File     : t123.py
    
    import smtplib
    from email.mime.multipart import MIMEMultipart
    from email.mime.text import MIMEText
    
    import my_key
    
    me = 'mail_address'
    you = ['mail_address1', 'mail_address2']
    text_file = '2.txt'
    
    msg = MIMEMultipart()
    msg['Subject'] = 'Subject'
    msg['From'] = me
    msg['To'] = ','.join(you)
    
    message = MIMEText('fp.read()')
    msg.attach(message)
    
    files = MIMEText(open('t.xls', 'rb').read(), 'base64', 'utf-8')
    files["Content-Type"] = 'application/octet-stream'
    files["Content-Disposition"] = 'attachment;filename="t.xls"'
    msg.attach(files)
    
    s = smtplib.SMTP('mail_host', 25)
    s.login(my_key.my_account, my_key.my_password)
    s.sendmail(me, you, msg.as_string())
    s.quit()
    
  • 相关阅读:
    shell test条件判断
    shell 变量
    shell 流程结构
    shell 正则表达式
    shell脚本常用参数
    snmp 简单的网络管理协议
    linux
    nmap
    git 基础操作
    linux 下 svn 更新代码
  • 原文地址:https://www.cnblogs.com/otfsenter/p/7767426.html
Copyright © 2011-2022 走看看