Commit 7007f164 authored by 赵威's avatar 赵威

update email

parent 4dcbd428
...@@ -22,11 +22,11 @@ from pyspark.sql.functions import concat_ws ...@@ -22,11 +22,11 @@ from pyspark.sql.functions import concat_ws
def send_email(app,id,e): def send_email(app,id,e):
# 第三方 SMTP 服务 # 第三方 SMTP 服务
mail_host = 'smtp.exmail.qq.com' # 设置服务器 mail_host = 'smtp.exmail.qq.com' # 设置服务器
mail_user = "gaoyazhe@igengmei.com" # 用户名 mail_user = "zhaowei@igengmei.com" # 用户名
mail_pass = "VCrKTui99a7ALhiK" # 口令 mail_pass = "Gengmei1234" # 口令
sender = 'gaoyazhe@igengmei.com' sender = 'zhaowei@igengmei.com'
receivers = ['gaoyazhe@igengmei.com'] # 接收邮件,可设置为你的QQ邮箱或者其他邮箱 receivers = ['zhaowei@igengmei.com'] # 接收邮件,可设置为你的QQ邮箱或者其他邮箱
e = str(e) e = str(e)
msg = MIMEMultipart() msg = MIMEMultipart()
part = MIMEText('app_id:'+id+':fail', 'plain', 'utf-8') part = MIMEText('app_id:'+id+':fail', 'plain', 'utf-8')
...@@ -37,12 +37,16 @@ def send_email(app,id,e): ...@@ -37,12 +37,16 @@ def send_email(app,id,e):
# message['Cc'] = ";".join(cc_reciver) # message['Cc'] = ";".join(cc_reciver)
msg['Subject'] = 'spark streaming:app_name:'+app msg['Subject'] = 'spark streaming:app_name:'+app
with open('error.txt','w') as f:
f.write(e) try:
f.close() with open('error.txt','w') as f:
part = MIMEApplication(open('error.txt', 'r').read()) f.write(e)
part.add_header('Content-Disposition', 'attachment', filename="error.txt") f.close()
msg.attach(part) part = MIMEApplication(open('error.txt', 'r').read())
part.add_header('Content-Disposition', 'attachment', filename="error.txt")
msg.attach(part)
except Exception as e:
print(e)
try: try:
smtpObj = smtplib.SMTP_SSL(mail_host, 465) smtpObj = smtplib.SMTP_SSL(mail_host, 465)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment