Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
MailmanProxy Class Reference
Inheritance diagram for MailmanProxy:
PureProxy SMTPServer dispatcher

Public Member Functions

def process_message
 
- Public Member Functions inherited from PureProxy
def process_message
 
- Public Member Functions inherited from SMTPServer
def __init__
 
def handle_accept
 
def process_message
 
- Public Member Functions inherited from dispatcher
def __init__
 
def __repr__
 
def add_channel
 
def del_channel
 
def create_socket
 
def set_socket
 

Additional Inherited Members

- Data Fields inherited from dispatcher
 connected
 
 socket
 
 family_and_type
 
- Static Public Attributes inherited from dispatcher
int debug = 0
 
int connected = 0
 
int accepting = 0
 
int closing = 0
 
 addr = None
 

Detailed Description

Definition at line 379 of file smtpd.py.

Member Function Documentation

def process_message (   self,
  peer,
  mailfrom,
  rcpttos,
  data 
)

Definition at line 380 of file smtpd.py.

References PureProxy._deliver(), dospath.join(), and dospath.split().

381  def process_message(self, peer, mailfrom, rcpttos, data):
382  from cStringIO import StringIO
383  from Mailman import Utils
384  from Mailman import Message
385  from Mailman import MailList
386  # If the message is to a Mailman mailing list, then we'll invoke the
387  # Mailman script directly, without going through the real smtpd.
388  # Otherwise we'll forward it to the local proxy for disposition.
389  listnames = []
390  for rcpt in rcpttos:
391  local = rcpt.lower().split('@')[0]
392  # We allow the following variations on the theme
393  # listname
394  # listname-admin
395  # listname-owner
396  # listname-request
397  # listname-join
398  # listname-leave
399  parts = local.split('-')
400  if len(parts) > 2:
401  continue
402  listname = parts[0]
403  if len(parts) == 2:
404  command = parts[1]
405  else:
406  command = ''
407  if not Utils.list_exists(listname) or command not in (
408  '', 'admin', 'owner', 'request', 'join', 'leave'):
409  continue
410  listnames.append((rcpt, listname, command))
411  # Remove all list recipients from rcpttos and forward what we're not
412  # going to take care of ourselves. Linear removal should be fine
413  # since we don't expect a large number of recipients.
414  for rcpt, listname, command in listnames:
415  rcpttos.remove(rcpt)
416  # If there's any non-list destined recipients left,
417  print >> DEBUGSTREAM, 'forwarding recips:', ' '.join(rcpttos)
418  if rcpttos:
419  refused = self._deliver(mailfrom, rcpttos, data)
420  # TBD: what to do with refused addresses?
421  print >> DEBUGSTREAM, 'we got refusals'
422  # Now deliver directly to the list commands
423  mlists = {}
424  s = StringIO(data)
425  msg = Message.Message(s)
426  # These headers are required for the proper execution of Mailman. All
427  # MTAs in existance seem to add these if the original message doesn't
428  # have them.
429  if not msg.getheader('from'):
430  msg['From'] = mailfrom
431  if not msg.getheader('date'):
432  msg['Date'] = time.ctime(time.time())
433  for rcpt, listname, command in listnames:
434  print >> DEBUGSTREAM, 'sending message to', rcpt
435  mlist = mlists.get(listname)
436  if not mlist:
437  mlist = MailList.MailList(listname, lock=0)
438  mlists[listname] = mlist
439  # dispatch on the type of command
440  if command == '':
441  # post
442  msg.Enqueue(mlist, tolist=1)
443  elif command == 'admin':
444  msg.Enqueue(mlist, toadmin=1)
445  elif command == 'owner':
446  msg.Enqueue(mlist, toowner=1)
447  elif command == 'request':
448  msg.Enqueue(mlist, torequest=1)
449  elif command in ('join', 'leave'):
450  # TBD: this is a hack!
451  if command == 'join':
452  msg['Subject'] = 'subscribe'
453  else:
454  msg['Subject'] = 'unsubscribe'
455  msg.Enqueue(mlist, torequest=1)
456 
457 

The documentation for this class was generated from the following file: