Ejemplo n.º 1
0
class RaindropLMTPServer(SMTPServer):
    def __init__(self, localaddr, remoteaddr):
        SMTPServer.__init__(self, localaddr, remoteaddr)
        self.processor = RaindropEmailProcessor()

        self.hbase = RaindropHBaseClient()

    def process_message(self, peer, mailfrom, rcpttos, data):
        #    print 'Receiving message from:', peer
        #    print 'Message addressed from:', mailfrom
        #    print 'Message addressed to  :', rcpttos
        #    print 'Message length        :', len(data)
        #    print 'Message               :', data

        message = self.processor.process(data)

        # Each recipient is a local user we need to deliver this message to.
        for user in rcpttos:
            [username, domain] = user.split("@")
            self._maildir_delivery(username, domain, data)
            self._hbase_delivery(username, domain, message, data)

        # Returning nothing indicates successful delivery
        return

    def _hbase_delivery(self, username, domain, message, data):
        self.hbase.save(username, domain, message, data)

    def _maildir_delivery(self, username, domain, data):
        try:
            path = os.path.join(os.path.expanduser(MAILDIR_DELIVERY_USER),
                                domain, username)
            mdir = Maildir(path)
            mdirid = mdir.add(data)
            print "Maildir Delivered %s@%s %s/%s" % (username, domain, path,
                                                     mdirid)
        except:
            # XXX log errors with maildir but continue
            print "Maildir delivery error %s@%s " % (username, domain)

    def handle_accept(self):
        conn, addr = self.accept()
        channel = RaindropLMTPChannel(self, conn, addr)
Ejemplo n.º 2
0
class RaindropLMTPServer(SMTPServer):

  def __init__(self, localaddr, remoteaddr):
    SMTPServer.__init__(self, localaddr, remoteaddr)
    self.processor = RaindropEmailProcessor()

    self.hbase = RaindropHBaseClient()

  def process_message(self, peer, mailfrom, rcpttos, data):
#    print 'Receiving message from:', peer
#    print 'Message addressed from:', mailfrom
#    print 'Message addressed to  :', rcpttos
#    print 'Message length        :', len(data)
#    print 'Message               :', data

    message = self.processor.process(data)

    # Each recipient is a local user we need to deliver this message to.
    for user in rcpttos:
      [username, domain] = user.split("@")
      self._maildir_delivery(username, domain, data)
      self._hbase_delivery(username, domain, message, data)

    # Returning nothing indicates successful delivery
    return

  def _hbase_delivery(self, username, domain, message, data):
    self.hbase.save(username, domain, message, data)

  def _maildir_delivery(self, username, domain, data):
    try:
      path = os.path.join(os.path.expanduser(MAILDIR_DELIVERY_USER), domain, username)
      mdir = Maildir(path)
      mdirid = mdir.add(data)
      print "Maildir Delivered %s@%s %s/%s" % (username, domain, path, mdirid)
    except:
      # XXX log errors with maildir but continue
      print "Maildir delivery error %s@%s " % (username, domain)

  def handle_accept(self):
    conn, addr = self.accept()
    channel = RaindropLMTPChannel(self, conn, addr)
Ejemplo n.º 3
0
    def __init__(self, localaddr, remoteaddr):
        SMTPServer.__init__(self, localaddr, remoteaddr)
        self.processor = RaindropEmailProcessor()

        self.hbase = RaindropHBaseClient()
Ejemplo n.º 4
0
  def __init__(self, localaddr, remoteaddr):
    SMTPServer.__init__(self, localaddr, remoteaddr)
    self.processor = RaindropEmailProcessor()

    self.hbase = RaindropHBaseClient()