(mail, spamc=False, cmd=False)
return score, returncode, spamassassin_result
Test a email with spamassassin.
Test a email with spamassassin.
Test a email with spamassassin .
def test_mail(mail, spamc=False, cmd=False):
    """Test a email with spamassassin."""
    score = "0/0\n"
    orig_code = None
    spamassassin_result = None
    returncode = None

    if cmd:
        satest = cmd
    elif spamc:
        # let spamc process mails larger than 500 KB if ISBG forwards them
        satest = ["spamc", "-E", "--max-size=268435450"]
    else:
        satest = ["spamassassin", "--exit-code"]

    proc = utils.popen(satest)

    try:
        spamassassin_result = proc.communicate(imaputils.mail_content(mail))[0]
        returncode = proc.returncode
        proc.stdin.close()
        score = utils.score_from_mail(spamassassin_result.decode(errors='ignore'))

    except Exception:  # pylint: disable=broad-except
        score = "-9999"

    return score, returncode, spamassassin_result
def test_mail ( mail , spamc = False , cmd = False ) : score = "0/0\n" orig_code = None spamassassin_result = None returncode = None if cmd : satest = cmd elif spamc : # let spamc process mails larger than 500 KB if ISBG forwards them satest = [ "spamc" , "-E" , "--max-size=268435450" ] else : satest = [ "spamassassin" , "--exit-code" ] proc = utils . popen ( satest ) try : spamassassin_result = proc . communicate ( imaputils . mail_content ( mail ) ) [ 0 ] returncode = proc . returncode proc . stdin . close ( ) score = utils . score_from_mail ( spamassassin_result . decode ( errors = 'ignore' ) ) except Exception : # pylint: disable=broad-except score = "-9999" return score , returncode , spamassassin_result