acl_smtp_data = acl_check_data acl_check_data_rspamd: warn set acl_m0 = ${dlfunc{/usr/local/libexec/exim/exim-dlfunc.so}{rspamd}\ {confRSPAMD_ADDRESS}{defer_ok}} warn condition = ${if eq{$acl_m0}{}{yes}{no}} log_message = RSPAMD connection failes add_header = X-Rspamd-Info: RSPAMD check failed on $primary_hostname set acl_m_contentscan_result = defer warn set acl_m0 = ${sg{${sg{$acl_m0}{\r\n}{\n}}}{\N\n+$\N}{\n}} warn condition = ${if match{$acl_m0}{\N^rspamd dlfunc:\s*\N}{yes}{no}} log_message = RSPAMD connection deferred: ${sg{$acl_m0}{\N^rspamd dlfunc:\s*\N}{}} add_header = X-Rspamd-Info: RSPAMD connection deferred on $primary_hostname: ${sg{$acl_m0}{\N^rspamd dlfunc:\s*\N}{}} set acl_m0 = set acl_m_contentscan_result = defer warn condition = ${if eq{$acl_m0}{}{no}{yes}} set acl_m1 = ${if match{$acl_m0}\ {\N^RSPAMD answer: RSPAMD/(\S+) 0 EX_OK\N}{$1}{}} # logwrite = RSPAMD check: RSPAMD protocol version: ${if eq{$acl_m1}{}{not found}{$acl_m1}} add_header = X-Rspamd-Protocol-Version: ${if eq{$acl_m1}{}{not found}{$acl_m1}} set acl_m0 = ${sg{$acl_m0}{\N^RSPAMD answer: RSPAMD/.+?\n\N}{}} warn condition = ${if eq{$acl_m0}{}{no}{yes}} set acl_m1 = ${if match{$acl_m0}{\N^((.+?\n)*?)Urls: ([^\n]*)\N}{$3}{}} set acl_m0 = ${if match{$acl_m0}{\N^((.+?\n)*?)Urls: ([^\n]*)\n((.*\n)*)$\N}{$1$4}{$acl_m0}} set acl_m1 = ${sg{$acl_m1}{\N, $\N}{}} condition = ${if eq{$acl_m1}{}{no}{yes}} # logwrite = RSPAMD check: RSPAMD Urls: $acl_m1 add_header = X-Rspamd-Urls: $acl_m1 warn condition = ${if eq{$acl_m0}{}{no}{yes}} set acl_m1 = ${if match{$acl_m0}{\N^((.+?\n)*?)Emails: ([^\n]*)\N}{$3}{}} set acl_m0 = ${if match{$acl_m0}{\N^((.+?\n)*?)Emails: ([^\n]*)\n((.*\n)*)$\N}{$1$4}{$acl_m0}} set acl_m1 = ${sg{$acl_m1}{\N, $\N}{}} condition = ${if eq{$acl_m1}{}{no}{yes}} # logwrite = RSPAMD check: RSPAMD Emails: $acl_m1 add_header = X-Rspamd-Emails: $acl_m1 warn condition = ${if eq{$acl_m0}{}{no}{yes}} set acl_m1 = ${if match{$acl_m0}{\N^((.+?\n)*?)Message-ID: ([^\n]*)\N}{$3}{}} set acl_m0 = ${if match{$acl_m0}{\N^((.+?\n)*?)Message-ID: ([^\n]*)\n((.*\n)*)$\N}{$1$4}{$acl_m0}} set acl_m1 = ${sg{$acl_m1}{\N, $\N}{}} condition = ${if eq{$acl_m1}{}{no}{yes}} # logwrite = RSPAMD check: RSPAMD Message-ID: $acl_m1 add_header = X-Rspamd-Message-ID: $acl_m1 warn set acl_m_rspamd_status = set acl_m_rspamd_score = condition = ${if eq{$acl_m0}{}{no}{yes}} acl = acl_process_rspamd_answer warn condition = ${if match{$acl_m_rspamd_status}{Spam}{yes}{no}} set acl_m_rspamd_status = Spam add_header = X-Rspamd-Status: Spam logwrite = RSPAMD check: Status is Spam warn condition = ${if match{$acl_m_rspamd_status}{Probably spam}{yes}{no}} set acl_m_rspamd_status = Probably spam add_header = X-Rspamd-Status: Probably spam logwrite = RSPAMD check: Status is Probably spam warn condition = ${if match{$acl_m_rspamd_status}{Ham}{yes}{no}} set acl_m_rspamd_status = Ham add_header = X-Rspamd-Status: Ham logwrite = RSPAMD check: Status is Ham warn condition = ${if match{$acl_m_rspamd_status}{unknown}{yes}{no}} set acl_m_rspamd_status = unknown add_header = X-Rspamd-Status: unknown logwrite = RSPAMD check: Status unknown warn condition = ${if eq{$acl_m_rspamd_score}{}{no}{yes}} condition = ${if eq{${extract{2}{:}{$acl_m_rspamd_score}}}{}{yes}{no}} add_header = X-Rspamd-Score: $acl_m_rspamd_score logwrite = RSPAMD score $acl_m_rspamd_score accept acl_process_rspamd_answer: accept condition = ${if eq{$acl_m0}{}{yes}{no}} warn set acl_m2 = ${sg{$acl_m0}{\N^(Metric:(?:.+?\n)+?)(Metric:(?:.+\n)+)*$\N}{\$1}} accept condition = ${if eq{$acl_m2}{}{yes}{no}} warn condition = ${if eq{$acl_m0}{acl_m2}{yes}{no}} set acl_m0 = warn set acl_m0 = ${sg{$acl_m0}{\N^(Metric:(?:.+?\n)+?)(Metric:(?:.+\n)+)*$\N}{\$2}} warn set acl_m3 = warn set acl_m1 = ${if match{$acl_m2}{\N^(?:.*?\n)*?Action:\s*(.+?)\n\N}{$1}{}} set acl_m3 = ${if eq{$acl_m1}{}{unknown}{\ ${if eq{$acl_m1}{reject}{Spam}{\ ${if eq{$acl_m1}{soft reject}{Probably spam}{\ ${if eq{$acl_m1}{rewrite subject}{Probably spam}{\ ${if eq{$acl_m1}{add header}{Probably spam}{\ ${if eq{$acl_m1}{greylist}{Probably spam}{\ ${if eq{$acl_m1}{no action}{Ham}{unknown}}\ }}\ }}\ }}\ }}\ }}\ }} set acl_m_rspamd_status = ${if eq{$acl_m_rspamd_status}{}{}{$acl_m_rspamd_status:}}${acl_m3} logwrite = RSPAMD check: RSPAMD status: $acl_m3 warn condition = ${if eq{$acl_m3}{}{no}{yes}} condition = ${if eq{$acl_m3}{unknown}{no}{yes}} set acl_m2 = ${sg{$acl_m2}{${expand:Action: $acl_m1}}{${expand:Status: $acl_m3}}} warn set acl_m1 = ${if match{$acl_m2}{\N^Metric: [^;]+?; (\S+?); (-?\d+\.\d+ / \d+\.\d+ / \d+\.\d+)\N}{$2}{}} set acl_m_rspamd_score = ${if eq{$acl_m_rspamd_score}{}{}{$acl_m_rspamd_score:}}${acl_m1} logwrite = RSPAMD check: RSPAMD scores: ${if eq{$acl_m1}{}{not found}{$acl_m1}} warn logwrite = RSPAMD check: RSPAMD report: ${if eq{$acl_m2}{}{not found}{$acl_m2}} add_header = X-Rspamd-Report: ${sg{$acl_m2}{\N\n(.)\N}{\n\t\$1}} warn acl = acl_process_rspamd_answer accept