SMTP settings: Timeout during testing

This commit is contained in:
Raphael Michel
2020-12-19 19:46:23 +01:00
parent 070b871254
commit 609203196b
2 changed files with 3 additions and 3 deletions

View File

@@ -528,7 +528,7 @@ class Event(EventMixin, LoggedModel):
return locking.LockManager(self)
def get_mail_backend(self, force_custom=False):
def get_mail_backend(self, timeout=None, force_custom=False):
"""
Returns an email server connection, either by using the system-wide connection
or by returning a custom one based on the event's settings.
@@ -542,7 +542,7 @@ class Event(EventMixin, LoggedModel):
password=self.settings.smtp_password,
use_tls=self.settings.smtp_use_tls,
use_ssl=self.settings.smtp_use_ssl,
fail_silently=False)
fail_silently=False, timeout=timeout)
else:
return get_connection(fail_silently=False)

View File

@@ -594,7 +594,7 @@ class MailSettings(EventSettingsViewMixin, EventSettingsFormView):
)
if request.POST.get('test', '0').strip() == '1':
backend = self.request.event.get_mail_backend(force_custom=True)
backend = self.request.event.get_mail_backend(force_custom=True, timeout=10)
try:
backend.test(self.request.event.settings.mail_from)
except Exception as e: