#!/usr/bin/env python
# coding=utf-8
from smtplib import SMTP
from email import MIMEText
from email import Header
from os.path import getsize
from sys import exit
from re import compile, IGNORECASE
#定义主机 帐号 密码 收件人 邮件主题
smtpserver = '10.0.10.191'
user = 'daxingyu'
password = '*******'
sender = 'dacoolbaby@163.com'
receiver = ('dacoolbaby@163.com','收件人',)
subject = u'Web
服务器tomcat日志错误信息'
From = u'xxx Web服务器'
To = u'服务器管理员'
#
发送邮件函数
def send_mail(error):
#定义邮件的头部信息
header = Header.Header
msg = MIMEText.MIMEText(error,'plain','utf-8')
msg['From'] = header(From)
msg['To'] = header(To)
msg['Subject'] = header(subject+'n')
#连接SMTP服务器,然后发送信息
smtp = SMTP(smtpserver)
smtp.login(user, password)
smtp.
sendmail(sender, receiver, msg.as_string())
smtp.close()
send_mail("hi hello")