~wilunix/mailman/lmtp

« back to all changes in this revision

Viewing changes to mailman/queue/lmtp.py

  • Committer: William Mead
  • Date: 2008-07-24 09:54:32 UTC
  • Revision ID: wam22@quant.staff.uscs.susx.ac.uk-20080724095432-v28jf5j9fxzgv28z
rev10: Added a method to Utils, Added some tests to the lmtp Doctest

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
    # The LHLO boolean determines if the LHLO command has been used or not during a session
126
126
    # False = LHLO has not been used
127
127
    # True = LHLO has been used
128
 
    # RFC 2033 requires the client to say LHLO to the server before mail can be sent
129
128
    LHLO = False
130
129
 
131
130
    def __init__(self, server, conn, addr):
175
174
            self.push('250 ENHANCEDSTATUSCODES')
176
175
 
177
176
    def smtp_MAIL(self, arg):
 
177
        # RFC 2033 requires the client to say LHLO to the server before mail can be sent
178
178
        if self.LHLO == False:
179
179
            self.push('503 '+EERR_551+' Need LHLO command')
180
180
            return
205
205
        if self.rcpttocheck(address) == 'EERR_511':
206
206
            self.push('550 '+EERR_511+': '+address)
207
207
            return
208
 
        # get subaddress
 
208
        # get subaddress and listname
209
209
        listname = self.listname(address)
210
210
        subaddress = self.subaddress(address)
211
211
        # Check if sender is authorised to post to list 
212
212
        if not subaddress in SUBADDRESS_NAMES:
213
 
            if self.listmembercheck(self._mailfrom, address) == 'EERR_572':
 
213
            if self.listmembercheck(self._mailfrom, listname) == 'EERR_572':
214
214
                self.push('550 '+EERR_572+': '+address)
215
215
                return   
216
216
        if subaddress in SUBADDRESS_NAMES:
356
356
        except:
357
357
            return 'Unknown Error'
358
358
    
359
 
    # rcpttocheck checks if list is a known list.
 
359
    # rcpttocheck checks if list is known
360
360
    def rcpttocheck(self, to):
361
361
        try:
362
362
            listnames = Channel.lists(self)
374
374
    def listmembercheck(self, mailfrom, address):
375
375
        mlist = config.db.list_manager.get(unicode(address))
376
376
        if mlist.generic_nonmember_action != 2:
377
 
            return False
 
377
            return True
378
378
        member = mlist.members.get_member(unicode(mailfrom))
379
379
        if member:
380
 
                return
 
380
            return True
381
381
        elif matches_p(mailfrom, mlist.accept_these_nonmembers): 
382
 
            return
 
382
            return True
383
383
        else:
384
384
            return 'EERR_572'
385
385