mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Improved SMTP testing
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
|
import logging
|
||||||
from smtplib import SMTPRecipientsRefused, SMTPSenderRefused
|
from smtplib import SMTPRecipientsRefused, SMTPSenderRefused
|
||||||
|
|
||||||
from django.core.mail.backends.smtp import EmailBackend
|
from django.core.mail.backends.smtp import EmailBackend
|
||||||
|
|
||||||
|
logger = logging.getLogger('pretix.base.email')
|
||||||
|
|
||||||
|
|
||||||
class CustomSMTPBackend(EmailBackend):
|
class CustomSMTPBackend(EmailBackend):
|
||||||
|
|
||||||
@@ -12,10 +15,12 @@ class CustomSMTPBackend(EmailBackend):
|
|||||||
self.connection.rcpt("test@example.org")
|
self.connection.rcpt("test@example.org")
|
||||||
(code, resp) = self.connection.mail(from_addr, [])
|
(code, resp) = self.connection.mail(from_addr, [])
|
||||||
if code != 250:
|
if code != 250:
|
||||||
|
logger.warn('Error testing mail settings, code %d, resp: %s' % (code, resp))
|
||||||
raise SMTPSenderRefused(code, resp, from_addr)
|
raise SMTPSenderRefused(code, resp, from_addr)
|
||||||
senderrs = {}
|
senderrs = {}
|
||||||
(code, resp) = self.connection.rcpt('')
|
(code, resp) = self.connection.rcpt('test@example.com')
|
||||||
if (code != 250) and (code != 251):
|
if (code != 250) and (code != 251):
|
||||||
|
logger.warn('Error testing mail settings, code %d, resp: %s' % (code, resp))
|
||||||
raise SMTPRecipientsRefused(senderrs)
|
raise SMTPRecipientsRefused(senderrs)
|
||||||
finally:
|
finally:
|
||||||
self.close()
|
self.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user