set SMTP timeout to 10 seconds and make it configurable, ref 9a735e8

pull/72/head
Martin Zimmermann 10 years ago
parent 72c38c2312
commit 3b248b293f

@ -162,6 +162,7 @@ also can moderate (=activate or delete) comments. Don't forget to configure
security = starttls security = starttls
to = to =
from = from =
timeout = 10
username username
self-explanatory, optional self-explanatory, optional
@ -188,6 +189,10 @@ to
from from
sender address, e.g. isso@example.tld sender address, e.g. isso@example.tld
timeout
specify a timeout in seconds for blocking operations like the
connection attempt.
Guard Guard
----- -----

@ -91,6 +91,10 @@ to =
# sender address, e.g. isso@example.tld # sender address, e.g. isso@example.tld
from = from =
# specify a timeout in seconds for blocking operations like the
# connection attempt.
timeout = 10
[guard] [guard]
# Enable basic spam protection features, e.g. rate-limit per IP address (/24 for # Enable basic spam protection features, e.g. rate-limit per IP address (/24 for

@ -128,6 +128,7 @@ class Config:
"username = ", "password = ", "username = ", "password = ",
"host = localhost", "port = 587", "security = starttls", "host = localhost", "port = 587", "security = starttls",
"to = ", "from = ", "to = ", "from = ",
"timeout = 10",
"[guard]", "[guard]",
"enabled = true", "enabled = true",
"ratelimit = 2", "ratelimit = 2",

@ -60,7 +60,7 @@ class SMTP(object):
klass = (smtplib.SMTP_SSL if self.conf.get('security') == 'ssl' else smtplib.SMTP) klass = (smtplib.SMTP_SSL if self.conf.get('security') == 'ssl' else smtplib.SMTP)
self.client = klass(host=self.conf.get('host'), self.client = klass(host=self.conf.get('host'),
port=self.conf.getint('port'), port=self.conf.getint('port'),
timeout=5) timeout=self.conf.getint('timeout'))
if self.conf.get('security') == 'starttls': if self.conf.get('security') == 'starttls':
self.client.starttls(); self.client.starttls();

Loading…
Cancel
Save