Also sanitize email address used for testing

This commit is contained in:
Kovid Goyal 2022-01-20 09:32:20 +05:30
parent da339e639d
commit e14f96454f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -67,8 +67,13 @@ class TestEmail(QDialog):
t.start()
def run_test(self):
from email.utils import parseaddr
addr = parseaddr(self.to.text().strip())[-1]
if not addr:
tb = f'{self.to.text().strip()} is not a valid email address'
else:
try:
tb = self.test_func(str(self.to.text())) or _('Email successfully sent')
tb = self.test_func(addr) or _('Email successfully sent')
except Exception:
import traceback
tb = traceback.format_exc()