def _filter(msgdata, mailparser, mdfolder, mailfilters):
    """Filter msgdata by mailfilters"""
    if mailfilters:
        for f in mailfilters:
            msg = mailparser.parse(StringIO(msgdata))
            rule = f(msg, folder=mdfolder)
            if rule:
                yield rule
    return