# do not scan messages submitted from our own hosts
# +relay_hosts is assumed to be a list of hosts in configuration
accept hosts = +relay_hosts

# do not scan messages from submission port (or maybe you want to?)
accept condition = ${if eq{$interface_port}{587}}

# skip scanning for authenticated users (if desired?)
accept authenticated = *

#allow large files though.
accept condition = ${if >={$message_size}{500k}{yes}{no}}

# scan the message with SpamAssasin
warn spam = ${lookup{$domain}lsearch{/etc/virtual/domainowners}{$value}{nobody}}/defer_ok

# 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

deny  message    = Message discarded as high-probability spam
        condition  = ${if eq{$spam_action}{reject}}

# Remove foreign headers
warn remove_header = x-spam-bar : x-spam-score : x-spam-report : x-spam-status

# add spam-score and spam-report header when "add header" action is recommended by rspamd
warn
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{$spam_action}{no action}}
add_header = X-Spam-Status: Yes

# add x-spam-bar header if score is positive
warn
condition = ${if >{$spam_score_int}{0}}
    add_header = X-Spam-Bar: $spam_bar