  .include_if_exists /etc/exim.easy_spam_fighter/check_message.conf.custom.pre

  accept  authenticated = *

    ################
    # Do some proper spam scanning and add on the score...
    #
    # We need to do some work here to feedback to the autowhitelister
    # such that any POSITIVE feeback given earlier by dint of being repeated email
    # is turned to NEGATIVE feedback here if it turns out to still be spam

	
  #Rspamd
  .include_if_exists /etc/exim/rspamd/check_message.conf

  #SpamAssassin
  warn
    condition = ${if !eq{$acl_c_rspamd}{1}}
    condition = ${if and { {< {$message_size}{EASY_SPAMASSASSIN_MAX_SIZE}} { <{$acl_m_easy69}{EASY_LIMIT}}}{1}{0}}
    condition = ${if !eq{$acl_m_spam_user}{nobody}}
    spam = $acl_m_spam_user:true/defer_ok
    set acl_m_easy69 = ${eval:$acl_m_easy69 + $spam_score_int}
    add_header = X-Spam-Score: $spam_score ($spam_bar)
    add_header = X-Spam-Report: $spam_report
    set acl_m_spam_assassin_has_run = 1

  warn
    condition = ${if !eq{$acl_c_rspamd}{1}}
	condition = ${if < {$message_size}{EASY_SPAMASSASSIN_MAX_SIZE}}
    condition = ${if !eq{$acl_m_spam_user}{nobody}}
    spam = $acl_m_spam_user/defer_ok
    set acl_m_spam_subject = ${perl{get_spam_subject}}
    add_header = X-Old-Subject:$h_Subject
    remove_header = Subject
    remove_header = X-Spam-Status
    add_header = Subject:$acl_m_spam_subject$h_Subject:
    add_header = X-Spam-Status: Yes, score=$spam_score, +EASY_IS_SPAM total spam score
    set acl_m_easy69 = ${eval:$acl_m_easy69 + EASY_IS_SPAM}

  warn
	condition = ${if !eq{$acl_c_rspamd}{1}}
    condition = ${if !eq{$acl_c_esf_skip}{1}}
    condition = ${if >= {$message_size}{EASY_SPAMASSASSIN_MAX_SIZE}}
    condition = ${if !eq{$acl_m_spam_user}{nobody}}
    remove_header = X-Spam-Status
    add_header = X-Spam-Status: No, message_size=$message_size larger than EASY_SPAMASSASSIN_MAX_SIZE

  drop
	condition = ${if !eq{$acl_c_rspamd}{1}}
    condition = ${if !eq{$acl_c_esf_skip}{1}}
    condition = ${if < {$message_size}{EASY_SPAMASSASSIN_MAX_SIZE}}
    condition = ${if !eq{$acl_m_spam_user}{nobody}}
    spam = $acl_m_spam_user/defer_ok
    set acl_m_high_score_drop = ${perl{get_spam_high_score_drop}}
    logwrite = ESF score is $spam_score_int / $acl_m_high_score_drop
    condition = ${if >={$spam_score_int}{$acl_m_high_score_drop}}
    message = High scoring spam message has been dropped
    logwrite = drop message based on users high-scoring-spam setting ($spam_score_int >= $acl_m_high_score_drop)

  warn
    remove_header = SpamTally
    condition = ${if !eq{$acl_m_spam_user}{nobody}}
    add_header = SpamTally: Final spam score: $acl_m_easy69

  warn
    remove_header = SpamTally
    condition = ${if eq{$acl_m_spam_user}{nobody}}
    add_header = SpamTally: Final spam score: unset because ESF not run (SpamAssassin unset, whitelist, or skippped)

  drop
    condition = ${if !eq{$acl_c_esf_skip}{1}}
    condition = ${if >={$acl_m_easy69}{EASY_HIGH_SCORE_DROP}{1}{0}}
    condition = ${if !eq{$acl_m_spam_user}{nobody}}
    message = Your message to <$recipients> was classified as SPAM.  Please add more content, cut down on HTML links, use fewer naughty words etc.  Also, ask your IT dept to make sure your mailserver has REVERSEDNS, SPF, DKIM, and is not on any black lists. Your score: $acl_m_easy69

  warn
    condition = ${if eq{$acl_c_esf_skip}{1}}
    logwrite = ESF evalutation skipped. Score: $acl_m_easy69

  .include_if_exists /etc/exim.easy_spam_fighter/check_dmarc.conf
  .include_if_exists /etc/exim.easy_spam_fighter/check_message.conf.custom.post

