From 788d291ab4336ca9157695da825fd14b76f1135d Mon Sep 17 00:00:00 2001 From: zypo Date: Wed, 8 Jul 2020 23:13:03 +0800 Subject: [PATCH] =?UTF-8?q?U=20=E4=BC=98=E5=8C=96=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=BC=82=E5=B8=B8=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_api/apps/setting/views.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spug_api/apps/setting/views.py b/spug_api/apps/setting/views.py index 40745be..6c75e11 100644 --- a/spug_api/apps/setting/views.py +++ b/spug_api/apps/setting/views.py @@ -55,14 +55,16 @@ def email_test(request): if error is None: try: if form.port == 465: - server = smtplib.SMTP_SSL(form.server, form.port) + server = smtplib.SMTP_SSL(form.server, form.port, timeout=3) else: - server = smtplib.SMTP(form.server, form.port) + server = smtplib.SMTP(form.server, form.port, timeout=3) server.login(form.username, form.password) - return json_response() + return json_response() + except Exception as e: - error = e.smtp_error.decode('utf-8') + error = f'{e}' return json_response(error=error) + return json_response(error=error)