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

Ken MacFerrin lists at macferrin.com
Mon Sep 25 05:40:47 CEST 2006


Mark, thank you so much.  That did it.  Sorry I neglected to include the
list in my last reply.  I've just applied your patch and the headers are
now perfect on each domain's lists.  Many hours of frustration have now
come to an end and I can re-enable spf and domainkeys for these lists.

Sincerely,
Ken


>>> What do you get in smtp-failure from this?
>> Currently I don't get anything.. I only get the errors I listed in my
>> last email in /var/log/mailman/error.  The /var/log/mailman/smtp-failure
>> log remains empty.
> 
> 
> Yes, I overlooked the blindingly obvious - see below.
> 
> 
>>>>        self.__conn.local_hostname = 'localhost'
>>>
>>> I don't know why you want to do this. Also, if you need to do it, it is
>>> better to give local_hostname='localhost' as an argument to the
>>> smtplib.SMTP() constructor.
>> I was doing this to hide the primary hostname for the machine from
>> showing up in the Received header for mail being passed from Mailman to
>> the outbound virtual domain smtp server since I don't want the headers
>> to list the machine's fqdn in messages for the virtual domains.  Before
>> doing this I was getting:
>> Received: from host.domain.name by smtp.virtualdomain.com (Postfix)...
>>
>> Doing this I now get:
>> Received: from localhost by smtp.virtualdomain.com (Postfix)...
> 
> 
> OK. I understand.
> 
> 
>>>>        self.__numsessions = mm_cfg.SMTP_MAX_SESSIONS_PER_CONNECTION
>>>>        self.__set_debuglevel = 1
>>>
>>> This does nothing useful. what you want is
>>>
>>>         self.__conn.set_debuglevel(1)
>>>
>>> and I would put it earlier - right after "self.__conn =
>>> smtplib.SMTP()". Debug messages should go to Mailman's error log.
>> I tried as you mentioned here but kept getting the following error when
>> doing so:
>> Sep 24 18:42:45 2006 (23668) Uncaught runner exception: Connection
>> instance has no attribute '_Connection__set_debuglevel'
> 
> 
> I don't understand the above error. It works for me.
> 
> 
>> Here's the code I'm using now:
>>
>>    def __connect(self):
>>        self.__conn = smtplib.SMTP()
>>        self.__set_debuglevel = 1
>>        if mlist:
>>            host = mlist.host_name
> 
> 
> The blindingly obvious - mlist is undefined.
> 
> 
>>        else:
>>            host = mm_cfg.SMTPHOST
>>        syslog('smtp-failure', 'host = %s, port = %s', host,
>> mm_cfg.SMTPPORT)
>>        x = self.__conn.connect(host, mm_cfg.SMTPPORT)
>>        syslog('smtp-failure', 'connect returns: %s', x)
>>        self.__conn.local_hostname = 'localhost'
>>        self.__numsessions = mm_cfg.SMTP_MAX_SESSIONS_PER_CONNECTION
> 
> 
> 
> The attached patch works. This is a 2.1.9 base, you may have to adjust
> the line numbers and of course remove the debugging stuff.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> --- Mailman/Handlers/SMTPDirect.py	2006-04-15 17:38:40.984375000 -0700
> +++ Mailman/Handlers/SMTPDirect.py	2006-09-24 19:45:40.671875000 -0700
> @@ -56,12 +56,21 @@
>  
>  # Manage a connection to the SMTP server
>  class Connection:
> -    def __init__(self):
> +    def __init__(self, mlist):
>          self.__conn = None
> +        self.mlist = mlist
>  
>      def __connect(self):
>          self.__conn = smtplib.SMTP()
> -        self.__conn.connect(mm_cfg.SMTPHOST, mm_cfg.SMTPPORT)
> +        self.__conn.set_debuglevel(1)
> +        if self.mlist:
> +            host = self.mlist.host_name
> +        else:
> +            host = mm_cfg.SMTPHOST
> +        syslog('smtp-failure', 'host = %s, port = %s', host, mm_cfg.SMTPPORT)
> +        x = self.__conn.connect(host, mm_cfg.SMTPPORT)
> +        syslog('smtp-failure', 'connect returns: %s', x)
> +        self.__conn.local_hostname = 'localhost'
>          self.__numsessions = mm_cfg.SMTP_MAX_SESSIONS_PER_CONNECTION
>  
>      def sendmail(self, envsender, recips, msgtext):
> @@ -149,7 +158,7 @@
>      # 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()
> +    conn = Connection(mlist)
>      try:
>          msgdata['undelivered'] = chunks
>          while chunks:




More information about the Mailman-Users mailing list