# General on/off switch.
	warn	set acl_m_rspamd_on = 0
	warn 	condition = ${if eq{$acl_m_rspamd}{1}}
			condition = ${if !eq{$acl_m_esf_skip}{1}}
			condition = ${if < {$message_size}{EASY_SPAMASSASSIN_MAX_SIZE}}
			condition = ${if !eq{$acl_m_spam_user}{nobody}}
			set acl_m_rspamd_on = 1

# scan the message with rspamd
	# This will set variables as follows:
	# $spam_action is the action recommended by rspamd
	# $spam_score is the message score (we unlikely need it)
	# $spam_score_int is spam score multiplied by 10
	# $spam_report lists symbols matched & protocol messages
	# $spam_bar is a visual indicator of spam/ham level
	warn	condition = ${if eq{$acl_m_rspamd_on}{1}}
			spam = nobody:true
			set acl_m_easy69 = ${eval:$acl_m_easy69 + $spam_score_int}
			set acl_m_spam_assassin_has_run = 1		

# use greylisting available in rspamd v1.3+
	defer	condition = ${if eq{$acl_m_rspamd_on}{1}}
			message = Please try again later
			condition  = ${if eq{$spam_action}{soft reject}}
	
#check for high-scoring spam.
	deny
			condition = ${if eq{$acl_m_rspamd_on}{1}}
			condition  = ${if eq{$spam_action}{reject}}
			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 = X-Spam-Bar : X-Spam-Score : X-Spam-Report : X-Spam-Status
	
	warn	condition = ${if eq{$acl_m_rspamd_on}{1}}
			condition  = ${if eq{$spam_action}{add header}}
			add_header = X-Spam-Score: $spam_score ($spam_bar)
			add_header = X-Spam-Report: $spam_report

# add x-spam-status header if message is not ham
	warn
			condition = ${if eq{$acl_m_rspamd_on}{1}}
			! condition  = ${if match{$spam_action}{^no action\$|^greylist\$}}
			set acl_m_spam_subject = ${perl{get_spam_subject}}
			add_header = X-Old-Subject:$h_Subject
			remove_header = Subject
			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}
			
# add x-spam-bar header if score is positive
	  warn
		condition = ${if >{$spam_score_int}{0}}
		add_header = X-Spam-Bar: $spam_bar

# add a note if the message was too big to be scanned.
	warn
			condition = ${if eq{$acl_m_rspamd}{1}}
			condition = ${if !eq{$acl_m_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
