Browse Source

邮件发送测试

Signed-off-by: Binren Zhnag <zhangbr@elab-plus.com>
Binren Zhnag 5 years ago
parent
commit
77ff1f63c8
3 changed files with 18 additions and 1 deletions
  1. 10 1
      email_util.py
  2. 8 0
      flask_app.py
  3. BIN
      resources/111.xlsx

+ 10 - 1
email_util.py

@@ -59,8 +59,17 @@ class EmailUtil(object):
     def quit_mail(self):
         self.smtp.quit()
 
+    dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+    def send_test(self):
+        send_email = EmailUtil()
+        send_email.send_mail('elab_test', '11', ['1285211525@qq.com'],
+                             mail_excel=r'{}/elab_mvp/resources/111.xlsx'.format(self.dir_path))
+        send_email.quit_mail()
+
 
 if __name__ == '__main__':
     send_email = EmailUtil()
-    send_email.send_mail('elab_test', mail_excel=r'D:\elab-code\elab_mvp\resources\tongce1.xlsx')
+    send_email.send_mail('elab_test', '11', ['1285211525@qq.com'], mail_excel=r'D:\elab-code\elab_mvp\resources\建业项目卡片信息合档-补id(1)(1).xlsx')
+    send_email.quit_mail()
     pass

+ 8 - 0
flask_app.py

@@ -5,6 +5,7 @@ from test_info import TestInfo
 from tongce import TongCe
 from apscheduler_elab import Config
 from flask_apscheduler import APScheduler
+from email_util import EmailUtil
 import decimal
 from report_push import ReportPush
 
@@ -198,6 +199,13 @@ def tongce_update_rule():
     return '更新成功!! 1'
 
 
+@app.route('/send_mail', methods=['GET', 'POST'])
+def send_mail():
+    mail = EmailUtil()
+    mail.send_test()
+    return 'success'
+
+
 @app.route('/update_other_city', methods=['GET', 'POST'])
 def update_other_city():
     response = {}

BIN
resources/111.xlsx