[Mailman-Users] multiple/dynamic outbound smtp hosts?

Ken MacFerrin lists at macferrin.com
Sun Sep 24 07:20:36 CEST 2006


I have a Debian server running 3 instances of postfix (2.3) with
separate domains that I would like to integrate with Mailman (2.1.8).
At this point I have the web interfaces and incoming mail to the lists
running fine using one Mailman install with
POSTFIX_STYLE_VIRTUAL_DOMAINS and the postfix-to-mailman.py script but
have one remaining problem with outbound smtp.  I'd like to avoid having
to maintain multiple Mailman installs but don't want any overlap between
the domains in the mailing lists email headers by having to relay .

My core issue is that I can't find a way to dynamically control what
smtp host Mailman uses for outbound mail.  I'd like to do something
similar to what amavis-new does for this situation and have Mailman use
the same domain name that it receives a message on for the outbound
mail.  The problem is that Mailman is receiving the mail through a pipe
transport so everything appears to come from localhost.  As an
alternative, I'd like to find a way to tell Mailman to use the domain
name of the mailing list for a message as the smtp server instead of the
static SMTPHOST.

I've been trying to modify SMTPDirect.py to do my bidding but my Python
skills are sorely lacking so any help would be greatly appreciated.  My
initial attempts have been to try to substitute the "mm_cfg.SMTPHOST"
variable with "mlist.host_name".  Obviously being able to implement a
solution directly in the mm_cfg file would be preferred but I'm not sure
that's possible..

original SMTPDirect code:
-------
class Connection:
    def __init__(self):
        self.__conn = None

    def __connect(self):
        self.__conn = smtplib.SMTP()
        self.__conn.connect(mm_cfg.SMTPHOST, mm_cfg.SMTPPORT)
        self.__numsessions = mm_cfg.SMTP_MAX_SESSIONS_PER_CONNECTION


modified code:
--------
class Connection:
    def __init__(self):
        self.__conn = None

    def __connect(self):
        self.__conn = smtplib.SMTP()
        syslog('smtp-failure', 'host = %s, port = %s', mlist.host_name,
mm_cfg.SMTPPORT)
        x = self.__conn.connect(mlist.host_name, mm_cfg.SMTPPORT)
        syslog('smtp-failure', 'connect returns: %s', x)
        self.__conn.local_hostname = 'localhost'
        self.__numsessions = mm_cfg.SMTP_MAX_SESSIONS_PER_CONNECTION
        self.__set_debuglevel = 1


-------
Unfortunately, this fails with the following errors in the log:

Sep 23 20:51:28 2006 (3126) Uncaught runner exception: SMTP instance has
no attribute 'sock'
Sep 23 20:51:28 2006 (3126) Traceback (most recent call last):
  File "/var/lib/mailman/Mailman/Queue/Runner.py", line 111, in _oneloop
    self._onefile(msg, msgdata)
  File "/var/lib/mailman/Mailman/Queue/Runner.py", line 167, in _onefile
    keepqueued = self._dispose(mlist, msg, msgdata)
  File "/var/lib/mailman/Mailman/Queue/OutgoingRunner.py", line 73, in
_dispose
    self._func(mlist, msg, msgdata)
  File "/var/lib/mailman/Mailman/Handlers/SMTPDirect.py", line 181, in
process
    conn.quit()
  File "/var/lib/mailman/Mailman/Handlers/SMTPDirect.py", line 102, in quit
    self.__conn.quit()
  File "smtplib.py", line 716, in quit
    self.docmd("quit")
  File "smtplib.py", line 377, in docmd
    self.putcmd(cmd,args)
  File "smtplib.py", line 333, in putcmd
    self.send(str)
  File "smtplib.py", line 318, in send
    if self.sock:
AttributeError: SMTP instance has no attribute 'sock'

Thanks,
Ken





More information about the Mailman-Users mailing list