Esempio n. 1
0
    def process_message(self, peer, mailfrom, rcpttos, data):
        try:
            echo('Processing message... %s, %s, %s' %
                 (peer, mailfrom, rcpttos))

            add_request = _contains(rcpttos,
                                    lambda address: 'add-hook@' in address)
            remove_request = _contains(
                rcpttos, lambda address: 'remove-hook@' in address)
            msg = Parser().parsestr(data)
            if add_request:
                self._add_hook(mailfrom, rcpttos, msg)
            elif remove_request:
                self._remove_hook(mailfrom, rcpttos, msg)
            else:
                self._forward(mailfrom, rcpttos, msg)
        except SMTPError as e:
            error('Failed to process message from %s.\n%s' % (mailfrom, e))
            return repr(e)
        except sqlalchemy.exc.IntegrityError as e:
            error('Ignoring request to add an existing webhook')
            return '554 Hook already exists.'
        except:
            e = sys.exc_info()[0]
            error('Failed to process message from %s' % mailfrom)
            error(traceback.format_exc())
            return '554 Error while processing message. %s' % e
Esempio n. 2
0
 def process_message(self, peer, mailfrom, rcpttos, data):
   msg = Parser().parsestr(data)
   try:
     echo('Processing message... %s, %s, %s' % (peer, mailfrom, rcpttos))
     forward_message(mailfrom, rcpttos, msg, self.webhook_url,
         self.authorization_token)
   except Exception, e:
     error('Failed to process message from %s' % mailfrom)
     error(traceback.format_exc())
Esempio n. 3
0
 def process_message(self, peer, mailfrom, rcpttos, data):
     msg = Parser().parsestr(data)
     try:
         echo('Processing message... %s, %s, %s' %
              (peer, mailfrom, rcpttos))
         forward_message(mailfrom, rcpttos, msg, self.webhook_url,
                         self.authorization_token)
     except Exception, e:
         error('Failed to process message from %s' % mailfrom)
         error(traceback.format_exc())
Esempio n. 4
0
  def process_message(self, peer, mailfrom, rcpttos, data):
    try:
      echo('Processing message... %s, %s, %s' % (peer, mailfrom, rcpttos))

      add_request = _contains(rcpttos, lambda address: 'add-hook@' in address)
      remove_request = _contains(rcpttos, lambda address: 'remove-hook@' in address)
      msg = Parser().parsestr(data)
      if add_request:
        self._add_hook(mailfrom, rcpttos, msg)
      elif remove_request:
        self._remove_hook(mailfrom, rcpttos, msg)
      else:
        self._forward(mailfrom, rcpttos, msg)
    except SMTPError as e:
      error('Failed to process message from %s.\n%s' % (mailfrom, e))
      return repr(e)
    except sqlalchemy.exc.IntegrityError as e:
      error('Ignoring request to add an existing webhook')
      return '554 Hook already exists.'
    except:
      e = sys.exc_info()[0]
      error('Failed to process message from %s' % mailfrom)
      error(traceback.format_exc())
      return '554 Error while processing message. %s' % e