# General on/off switch. warn set acl_m_rspamd_on = 0 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}} set acl_m_rspamd_on = 1 warn condition = ${if eq{$acl_c_rspamd}{1}} condition = ${if eq{$acl_m_rspamd_on}{0}} logwrite = Rspamd should be on but was skipped for some reason: acl_c_esf_skip=$acl_c_esf_skip OR (message_size=$message_size) >= EASY_SPAMASSASSIN_MAX_SIZE OR (acl_m_spam_user=$acl_m_spam_user)==nobody # 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+ # removed for now, requires redis back-end for data logging: # https://rspamd.com/doc/modules/greylisting.html # defer condition = ${if eq{$acl_m_rspamd_on}{1}} # message = Please try again later # condition = ${if eq{$spam_action}{greylist}} # logwrite = defer message with rspamd greylisting. #'soft reject' can be returned for other things, like rate limiting. defer condition = ${if eq{$acl_m_rspamd_on}{1}} message = Please try again later condition = ${if eq{$spam_action}{soft reject}} logwrite = defer message with rspamd 'soft reject'. #check for high-scoring spam. deny condition = ${if eq{$acl_m_rspamd_on}{1}} condition = ${if eq{$spam_action}{reject}} #when rspamd hangs, exim just adds empty spam_score/spam_score_int, and writes 'Yes, score=, ...' in the headers condition = ${if def:spam_score_int} 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) deny condition = ${if eq{$acl_m_rspamd_on}{1}} condition = ${if eq{$spam_action}{reject}} #when rspamd hangs, exim just adds empty spam_score/spam_score_int, and writes ‘Yes, score=, ...’ in the headers condition = ${if def:spam_score_int} message = High scoring spam message has been dropped, likely blacklist logwrite = High scoring spam message has been dropped, likely blacklist 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}} #when rspamd hangs, exim just adds empty spam_score/spam_score_int, and writes 'Yes, spam_score=, ...' in the headers condition = ${if def:spam_score} 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}} #when rspamd hangs, exim just adds empty spam_score/spam_score_int, and writes 'Yes, spam_score=, ...' in the headers condition = ${if def:spam_score} ! 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 rspamd failed to scan the message. warn condition = ${if eq{$acl_c_rspamd}{1}} condition = ${if !eq{$acl_c_esf_skip}{1}} condition = ${if !def:spam_score} condition = ${if !eq{$acl_m_spam_user}{nobody}} remove_header = X-Spam-Status add_header = X-Spam-Status: No, spam_score was empty, meaning rspamd failed to scan the message # add a note if the message was too big to be scanned. 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