Setup instructions for Spamassassin on Ubuntu Server 24.04.4 LTS using Sendmail

Ted Mittelstaedt <[email protected]> Thu, 16 Apr 2026 00:42:39 -0700
Newsgroups gmane.mail.spam.spamassassin.general
Message-ID <[email protected]>
The following are the steps I used for this.   Every guide I came across 
to do it was wrong and useless, however this one:

https://oneuptime.com/blog/post/2026-01-15-configure-spamassassin-ubuntu/view

skipping over the beginning (which was all wrong) the info after the 
section "Custom Rules" is not that terrible.

Note the Linux community almost always reaches for postfix because that 
is what they know, very few of them use sendmail and often when you see 
sendmail mentioned it's actually the postfix sendmail stub program not 
the real sendmail.

With that out of the way:

1) Install Ubuntu Server and configure to ssh into it, static IP, add 
name to /etc/hosts, ntp time sync it, set correct timezone, hostname, 
forward and reverse dns records, setup backups, update, etc.

2)  apt-get install sendmail

this installs version 8.18.1 of sendmail.

(8.18.2 is the latest version of sendmail)

3) run the script

sendmailconfig

4) test local delivery

# /usr/sbin/sendmail tedm
From: tedm@localhost
Subject: test

test
.

cat /var/mail/tedm
make sure mail is there

5) Add the IP address on your machines interface you want your machine 
to receive mail on

cd /etc/mail
add
DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=86.75.30.9')dnl

to sendmail.mc

make
  /etc/init.d/sendmail reload

6) Test from another host make sure your getting mail

7) apt install spamassassin
  systemctl enable spamd

cd /etc/spamassassin
  cp  local.cf  local.cf.installed
  vi local.cf

make your configuration changes and save

  systemctl start spamd

8)  cd /etc/mail
mkdir -p /etc/mail/spamassassin

vi /etc/mail/spamassassin/spamassassin.m4

Put in:

dnl
dnl Process mail through spamassassin
dnl
define(`confMILTER_MACROS_ENVFROM', `i, {auth_type}, {auth_authen}, 
{auth_ssf}, {auth_author}, {mail_mailer}, {mail_host}, {mail_addr}, r, 
b, v, Z')dnl
define(`confMILTER_MACROS_ENVRCPT', `{auth_type}, r, v, Z')dnl
INPUT_MAIL_FILTER(`spamassassin', 
`S=local:/var/run/spamass/spamass.sock, F=, T=C:15m;S:4m;R:4m;E:10m')dnl

9)  add this template to the main sendmail.mc
cd /etc/mail
  cp sendmail.mc sendmail.mc.nospamassassin

  vi sendmail.mc

add:

include(`/etc/mail/spamassassin/spamassassin.m4')dnl

right before MAILER_DEFINITIONS  and save

10)  install spamass-milter

service spamd stop

apt-get install spamass-milter

cd /etc/default

vi spamass-milter

uncomment and modify:
SOCKETOWNER="spamass-milter:spamass-milter"

save

systemctl enable spamass-milter

service spamd start

  systemctl start spamass-milter

As of this writing all of the Ubuntu packages install correct 
config/default files for systemctl and so on

The spamassassin package is version 4.0.2 for this version of Ubuntu:

https://packages.ubuntu.com/noble/spamassassin

The spamass-milter is version 0.4.0

https://packages.ubuntu.com/noble/spamass-milter

Note that the Ubuntu packager modified all of the prefixes.

So just downloading it and compiling the latest version will put it in 
/usr/local/sbin instead of /usr/sbin and so on for all the other locations.

Ted