欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

python发邮件

程序员文章站 2022-07-14 15:52:20
...
代码要最简化
import datetime
import MySQLdb
import sys
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
__author__ = 'ninghao'
def send_mail():
        me = "mactonish@163.com"
        you = "ninghao@sohu-inc.com"
        msg = MIMEMultipart('alternative')
        msg['Subject'] = "dean , its what u want "
        msg['From'] = me
        msg['To'] = you
        text = "dean , the thing what u want , I send to you !!!! 2324211232"
        html = """\
        <html>
          <head></head>
          <body>
            <p>Hi!<br>
               news , mike is dead !
            </p>
          </body>
        </html>
        """
        part1 = MIMEText(text, 'plain')
        part2 = MIMEText(html, 'html')
        msg.attach(part1)
        msg.attach(part2)
        s = smtplib.SMTP()
        s.connect('smtp.163.com',25)
        s.login("mactonish","mima")
        s.sendmail(me, you, msg.as_string())
        s.close()
if __name__ == "__main__":
    send_mail()
    print "haha"

一直top
#!/usr/bin/python -u 
import os
import sys
import subprocess
import time


while True:
        stdout = subprocess.Popen("top -bn 1",shell=True,stdout = subprocess.PIPE)
        print stdout.communicate()[0]
        time.sleep(15)
相关标签: mail