diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in index 9105d2e4b53a5ebb323e2ad6e31e90b00fca8bb2..c2c0d82429b4d77217e57b57ea9bf42fc1573358 100644 --- a/Mailman/Defaults.py.in +++ b/Mailman/Defaults.py.in @@ -588,6 +588,8 @@ MAX_DELIVERY_THREADS = 0 SMTPHOST = 'localhost' SMTPPORT = 0 # default from smtplib +CUSTOM_SMTP_SERVERS = {} + # Command for direct command pipe delivery to sendmail compatible program, # when DELIVERY_MODULE is 'Sendmail'. SENDMAIL_CMD = '/usr/lib/sendmail' diff --git a/Mailman/Handlers/SMTPDirect.py b/Mailman/Handlers/SMTPDirect.py index 7a9e83154385bd9c2ccf371104e39a587b5a8f8e..3b3edfe6202788abefab15918d8a9ba1b8fee3b5 100644 --- a/Mailman/Handlers/SMTPDirect.py +++ b/Mailman/Handlers/SMTPDirect.py @@ -73,15 +73,20 @@ class SMTPRR(smtplib.SMTP): return socket.create_connection((host, port), timeout) # Manage a connection to the SMTP server +# Support overriding SMTP server host/port on a per-list basis. class Connection: - def __init__(self): + def __init__(self, server_addr_override=None): + self._smtphost = mm_cfg.SMTPHOST + self._smtpport = mm_cfg.SMTPPORT + if server_addr_override is not None: + self._smtphost, self._smtpport = server_addr_override self.__conn = None def __connect(self): self.__conn = SMTPRR( local_hostname=mm_cfg.SMTP_HELO_HOST) self.__conn.set_debuglevel(mm_cfg.SMTPLIB_DEBUG_LEVEL) - self.__conn.connect(mm_cfg.SMTPHOST, mm_cfg.SMTPPORT) + self.__conn.connect(self._smtphost, self._smtpport) if mm_cfg.SMTP_AUTH: if mm_cfg.SMTP_USE_TLS: try: @@ -199,7 +204,8 @@ def process(mlist, msg, msgdata): # This means at worst, the last chunk for which delivery was attempted # could get duplicates but not every one, and no recips should miss the # message. - conn = Connection() + smtpaddr = mm_cfg.CUSTOM_SMTP_SERVERS.get(mlist.internal_name()) + conn = Connection(smtpaddr) try: msgdata['undelivered'] = chunks while chunks: