milvus/ci/jenkins/scripts/mail.py
del-zhenwu 8f88529fc1 Add nightly test notification && improve test case stability (#1056)
* Update framework

* remove files

* Remove files

* Remove ann-acc cases && Update java-sdk cases

* change cn to en

* [skip ci] remove doc test

* [skip ci] change cn to en

* Case stability

* Add mail notification when test failed

* Add main notification

* Add main notification

* gen milvus instance from utils

* Distable case with multiprocess

* Add mail notification when nightly test failed

* add milvus handler param

* add http handler

Co-authored-by: quicksilver <zhifeng.zhang@zilliz.com>
2020-01-17 09:59:49 +08:00

37 lines
1009 B
Python

# -*- coding: utf-8 -*-
import sys
import logging
from email.mime.text import MIMEText
from email.header import Header
import smtplib
SMS_DEFAULT_TO_LIST = [
"dev.milvus@zilliz.com",
]
def send_email(subject, content, token, receivers=None):
sender = 'test@zilliz.com'
message = MIMEText(content, 'html', 'utf-8')
message['From'] = Header("Daily Test")
message['To'] = Header("dev.milvus")
message['Subject'] = Header(subject, 'utf-8')
try:
smtp_obj = smtplib.SMTP('smtp.exmail.qq.com')
if receivers is None:
receivers = SMS_DEFAULT_TO_LIST
smtp_obj.login(sender, token)
result = smtp_obj.sendmail(sender, receivers, message.as_string())
except smtplib.SMTPException as e:
logging.error(str(e))
finally:
smtp_obj.quit()
if __name__ == "__main__":
if len(sys.argv) != 4:
sys.exit()
subject = sys.argv[1]
content = sys.argv[2]
token = sys.argv[3]
send_email(subject, content, token)