code: def parse_received(received):
      
  
      values_by_clause = {}
      for pattern in RECEIVED_COMPILED_LIST:
          matches = [match for match in pattern.finditer(received)]
  
          if len(matches) == 0:
              # no matches for this clause, but it's ok! keep going!
              log.debug("No matches found for %s in %s" % (
                  pattern.pattern, received))
              continue
          elif len(matches) > 1:
              # uh, can't have more than one of each clause in a received.
              # so either there's more than one or the current regex is wrong
              msg = "More than one match found for %s in %s" % (
                  pattern.pattern, received)
              log.error(msg)
              raise MailParserReceivedParsingError(msg)
          else:
              # otherwise we have one matching clause!
              log.debug("Found one match for %s in %s" % (
                  pattern.pattern, received))
              match = matches[0].groupdict()
              if six.PY2:
                  values_by_clause[match.keys()[0]] = match.values()[0]
              elif six.PY3:
                  key = list(match.keys())[0]
                  value = list(match.values())[0]
                  values_by_clause[key] = value
  
      if len(values_by_clause) == 0:
          # we weren't able to match anything...
          msg = "Unable to match any clauses in %s" % (received)
          log.error(msg)
          raise MailParserReceivedParsingError(msg)
      return values_by_clause
docs: Parse a single received header.
      Return a dictionary of values by clause.
  
      Arguments:
          received {str} -- single received header
  
      Raises:
          MailParserReceivedParsingError -- Raised when a
              received header cannot be parsed
  
      Returns:
          dict -- values by clause