<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[iRedMail — Migrate from amavis/spamassassin to rspamd]]></title>
		<link>https://forum.iredmail.org/topic21228-migrate-from-amavisspamassassin-to-rspamd.html</link>
		<atom:link href="https://forum.iredmail.org/feed-rss-topic21228.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Migrate from amavis/spamassassin to rspamd.]]></description>
		<lastBuildDate>Thu, 15 Oct 2026 00:58:46 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Migrate from amavis/spamassassin to rspamd]]></title>
			<link>https://forum.iredmail.org/post92271.html#p92271</link>
			<description><![CDATA[<p>Thanks for sharing. <img src="https://forum.iredmail.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (ZhangHuangbin)]]></author>
			<pubDate>Thu, 15 Oct 2026 00:58:46 +0000</pubDate>
			<guid>https://forum.iredmail.org/post92271.html#p92271</guid>
		</item>
		<item>
			<title><![CDATA[Migrate from amavis/spamassassin to rspamd]]></title>
			<link>https://forum.iredmail.org/post92270.html#p92270</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>======== Required information ====<br />- iRedMail version (check /etc/iredmail-release):&nbsp; iRedMail-1.8.8<br />- Linux/BSD distribution name and version: Debian 13<br />- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL<br />- Web server (Apache or Nginx): Nginx<br />- Manage mail accounts with iRedAdmin-Pro? No<br />- Related log if you&#039;re reporting an issue: -<br />====</p></blockquote></div><p>Hi, since I successfully migrated a production server based on the iRedMail script from amavisd/spamassassin to rspamd, I&#039;d like to share the steps I took and possibly validate whether I skipped any important configuration stages. The migration was done on Debian 13/MySQL/NGINX (not the PRO version), so the paths I give are the correct ones for my setup.</p><p><strong>1. Backup</strong></p><p>Just in case we dump the versions and secure a basic backup.</p><div class="codebox"><pre><code>cd /root
mkdir -p /root/migrate-rspamd &amp;&amp; cd /root/migrate-rspamd
tar czf etc-$(date +%F).tgz /etc/postfix /etc/amavis /etc/mail/spamassassin /etc/spamassassin /etc/dovecot /etc/clamav /var/lib/dkim /var/vmail/sieve
tar czf cron-$(date +%F).tgz /var/spool/cron/crontabs /etc/default/spamassassin
mysqldump --single-transaction amavisd &gt; amavisd.sql

dpkg -l | grep -Ei &#039;amavis|spamassassin|clamav|rspamd&#039; &gt; pkgs.txt
chmod 600 *.tgz amavisd.sql</code></pre></div><p><strong>2. Installing rspamd + redis:</strong></p><p>I couldn&#039;t use links in post so replace:<br />FIRST = rspamd.com/apt-stable/gpg.key<br />SECOND = rspamd.com/apt-stable/<br />with https on the begining</p><div class="codebox"><pre><code>sudo apt install curl gnupg ca-certificates lsb-release
curl -fsSL FIRST | gpg --dearmor -o /usr/share/keyrings/rspamd.gpg
echo &quot;deb [signed-by=/usr/share/keyrings/rspamd.gpg] SECOND trixie main&quot; &gt; /etc/apt/sources.list.d/rspamd.list
sudo apt update
sudo apt install rspamd redis-server</code></pre></div><p>verification</p><div class="codebox"><pre><code>systemctl enable --now redis-server &amp;&amp; redis-cli ping</code></pre></div><p><strong>3. Configuration</strong></p><p>The DKIM keys can be kept or regenerated. I kept them.</p><p>In /etc/rspamd/local.d/redis.conf</p><div class="codebox"><pre><code>servers = &quot;127.0.0.1:6379&quot;;</code></pre></div><p>/etc/rspamd/local.d/dkim_signing.conf</p><div class="codebox"><pre><code>enabled = true;
selector = &quot;dkim&quot;;
path = &quot;/var/lib/dkim/$domain.pem&quot;;

sign_authenticated = true;
sign_local = true;
sign_inbound = false;

allow_username_mismatch = true;
allow_hdrfrom_mismatch = true;
check_pubkey = true;</code></pre></div><p><strong>3.1 ClamAV</strong></p><p>check the path:</p><div class="codebox"><pre><code>grep LocalSocket /etc/clamav/clamd.conf

usermod -aG clamav _rspamd
systemctl restart rspamd</code></pre></div><p>In /etc/rspamd/local.d/antivirus.conf</p><div class="codebox"><pre><code>clamav {
  servers = &quot;/var/run/clamav/clamd.ctl&quot;;   # whatever grep LocalSocket /etc/clamav/clamd.conf returned
  symbol  = &quot;CLAM_VIRUS&quot;;
  type    = &quot;clamav&quot;;
  action  = &quot;reject&quot;;
  scan_mime_parts = true;
}</code></pre></div><p>Verification</p><div class="codebox"><pre><code>sudo -u _rspamd test -w /var/run/clamav/clamd.ctl &amp;&amp; echo &quot;socket OK&quot;</code></pre></div><p><strong>3.2 I carry over the headers that were present in Amavisd.</strong></p><p>/etc/rspamd/local.d/milter_headers.conf</p><div class="codebox"><pre><code>use = [&quot;spam-header&quot;,&quot;x-spam-status&quot;,&quot;x-spam-level&quot;,&quot;authentication-results&quot;,&quot;x-virus&quot;,&quot;add-headers&quot;,&quot;x-spamd-result&quot;,&quot;x_spam_score&quot;];
routines {
  spam-header {
    header = &quot;X-Spam-Flag&quot;;
    value  = &quot;YES&quot;;
    remove = 0;
  }
  x-virus {
    symbols = [&quot;CLAM_VIRUS&quot;];
  }
  add-headers {
    headers {
      &quot;X-Virus-Scanned&quot; = &quot;rspamd&quot;;
    }
    remove = 0;
  }
}

custom {
  x_spam_score = &lt;&lt;EOD
return function(task, common_meta)
  local ms = task:get_metric_score()
  if not ms then return nil end
  return nil,
    { [&#039;X-Spam-Score&#039;] = string.format(&#039;%.2f&#039;, ms[1]) },
    { [&#039;X-Spam-Score&#039;] = 0 },
    {}
end
EOD;
}</code></pre></div><p><strong>3.3 Thresholds</strong></p><p>The thresholds in rspamd are different; below are the ones I added in /etc/rspamd/local.d/actions.conf</p><div class="codebox"><pre><code>reject = 15;            # final rejection
rewrite_subject = 7;    # prefix [SPAM] in the subject
add_header = 6;         # tag (X-Spam-Flag) -&gt; Junk
greylist = 4;           # greylisting

# subject for the &#039;rewrite subject&#039; action (%s = original subject)
subject = &quot;[SPAM] %s&quot;;</code></pre></div><p><strong>3.4 Web UI panel</strong></p><p>If anyone wants such a panel, per the rspamd documentation</p><div class="codebox"><pre><code>rspamadm pw

/etc/rspamd/local.d/worker-controller.inc
bind_socket = &quot;127.0.0.1:11334&quot;;
password = &quot;$2$...&quot;;

rspamadm configtest &amp;&amp; systemctl restart rspamd</code></pre></div><p><strong>3.5 Finish</strong></p><p>We apply the configuration:</p><div class="codebox"><pre><code>rspamadm configtest
systemctl enable --now rspamd
systemctl restart rspamd
systemctl status rspamd --no-pager
ss -tlnp | grep -E &#039;11332|11333|11334&#039;</code></pre></div><p><strong>4. Postfix</strong></p><p>In /etc/postfix/main.cf you should comment out</p><div class="codebox"><pre><code>content_filter = smtp-amavis:[127.0.0.1]:10024</code></pre></div><p>as well as</p><div class="codebox"><pre><code>smtp-amavis_destination_recipient_limit = 1</code></pre></div><p>In /etc/postfix/master.cf</p><p>You should comment out all occurrences of</p><div class="codebox"><pre><code>-o content_filter=smtp-amavis...</code></pre></div><p>We run</p><div class="codebox"><pre><code>postconf -X pickup/unix/content_filter</code></pre></div><p><strong>4.1 DKIM keys (if you keep the already generated ones)</strong></p><div class="codebox"><pre><code>chown -R _rspamd:_rspamd /var/lib/dkim
chmod 0400 /var/lib/dkim/*.pem
find /var/lib/dkim -type d -exec chmod 0700 {} \;
sudo -u _rspamd head -c1 /var/lib/dkim/dts-frankfurt.de.pem &gt;/dev/null &amp;&amp; echo &quot;keys OK&quot;</code></pre></div><p><strong>4.2 Reload postfix:</strong></p><div class="codebox"><pre><code>postconf -e &#039;smtpd_milters = inet:127.0.0.1:11332&#039;
postconf -e &#039;non_smtpd_milters = inet:127.0.0.1:11332&#039;
postconf -e &#039;milter_protocol = 6&#039;
postconf -e &#039;milter_default_action = accept&#039;
postfix check &amp;&amp; systemctl reload postfix</code></pre></div><p><strong>5. Disabling amavisd and spamassassin</strong></p><div class="codebox"><pre><code>systemctl disable --now amavisd spamassassin</code></pre></div><p>Comment out the crons</p><div class="codebox"><pre><code>1   2   *   *   *   python3 /opt/www/iredadmin/tools/cleanup_amavisd_db.py &gt;/dev/null</code></pre></div><p>Verification:</p><p>You can verify correctness in the logs: </p><div class="codebox"><pre><code>tail -f /var/log/mail.log</code></pre></div><p>Check the signing with the tool:</p><div class="codebox"><pre><code>rspamc -u postmaster@your_domain.com &lt;&lt;&#039;EOF&#039; | grep DKIM_SIGNED  //change this
From: postmaster@your_domain.com  //change this
To: someone@someone.com  //change this
Subject: DKIM test

Test message
EOF</code></pre></div><p>Spam test:</p><div class="codebox"><pre><code>printf &#039;Subject: test gtube\n\nXJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X\n&#039; \
  | sendmail postmaster@your-domain.com  //change this</code></pre></div><p><strong>======</strong></p><p>I hope I didn&#039;t miss anything. iRedAPD reads the tables from the database so I left it as is; I assume the lists will still work. Unfortunately Bayes has to be trained from scratch. You can do it on the emails you have.</p><p>If anyone had the Bayes auto-learning scripts from the iRedMail documentation configured, they need to be changed:</p><div class="codebox"><pre><code># before: output=&quot;$(${SA_LEARN} --spam ${SPOOL_LEARN_SPAM_DIR})&quot;
output=&quot;$(/usr/bin/rspamc learn_spam ${SPOOL_LEARN_SPAM_DIR})&quot;
...
# before: output=&quot;$(${SA_LEARN} --ham ${SPOOL_LEARN_HAM_DIR})&quot;
output=&quot;$(/usr/bin/rspamc learn_ham ${SPOOL_LEARN_HAM_DIR})&quot;</code></pre></div><p>If any messages get stuck in the Postfix queue, they need to be requeued:</p><div class="codebox"><pre><code>postsuper -r ALL
postqueue -f
postqueue -p</code></pre></div><p>There are differences in behavior:<br />Amavis did DISCARD, rspamd does REJECT for messages considered infected.</p><p>iRedAPD — wblist works but the per-user thresholds from amavis.policy are no longer used.</p><p>By default rspamd does not use the system resolver. It has to be changed in the settings.</p><p>If you have experience with this kind of migration or notice anything I might have missed, please let me know. I assume everyone will need to adjust the Rspamd configuration to their own needs starting from the defaults. I hope I didn&#039;t miss anything <img src="https://forum.iredmail.org/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p>]]></description>
			<author><![CDATA[null@example.com (royalfoxy)]]></author>
			<pubDate>Wed, 14 Oct 2026 21:52:03 +0000</pubDate>
			<guid>https://forum.iredmail.org/post92270.html#p92270</guid>
		</item>
	</channel>
</rss>
