SPAMD(1)
π SPAMD(1)
okay so. this is spamd, and the whole thing comes to you straight out of the User Contributed Perl Documentation section of the manual β¨ she's long, she's iconic, and she's split into three parts β this is part one, so stay with me bestie π«Ά
β¨ NAME β¨
spamd β the daemonized version of spamassassin. that's it, that's the name, she's a daemon now π
π¦ SYNOPSIS π¦
spamd [options]
and the options are... okay there are a LOT of them, but every single one is important, so we're doing all of them, no skipping π
-l,--allow-tellβ allow learning/reporting-c,--create-prefsβ create user preferences files-C path,--configpath=pathβ path for default config files--siteconfigpath=pathβ path for site configs--cf='config line'β additional line of configuration--pre='config line'β additional line of.pre(prepended to configuration)-d,--daemonizeβ daemonize-h,--helpβ print usage message-i [ip_or_name[:port]],--listen=[ip_or_name[:port]]β listen on IP addr and port-p port,--port=portβ listen on specified port, may be overridden by-i-4,--ipv4-only,--ipv4β use IPv4 where applicable, disables IPv6-6β use IPv6 where applicable, disables IPv4-A host,...,--allowed-ips=..,..β restrict to IP addresses which can connect-m num,--max-children=numβ allow maximumnumchildren--min-children=numβ allow minimumnumchildren--min-spare=numβ lower limit for number of spare children--max-spare=numβ upper limit for number of spare children--max-conn-per-child=numβ maximum connections accepted by child before it is respawned--round-robinβ use traditional prefork algorithm--timeout-tcp=secsβ connection timeout for client headers--timeout-child=secsβ connection timeout for message checks-q,--sql-configβ enable SQL config (needs-x)-Q,--setuid-with-sqlβ enable SQL config (needs-x, enables use of-H)--ldap-configβ enable LDAP config (needs-x)--setuid-with-ldapβ enable LDAP config (needs-x, enables use of-H)--virtual-config-dir=dirβ enable pattern based Virtual configs (needs-x)-r pidfile,--pidfileβ write the process id topidfile-s facility,--syslog=facilityβ specify the syslog facility--syslog-socket=typeβ how to connect to syslogd--log-timestamp-fmt=fmtβstrftime(3)format for timestamps, may be empty to disable timestamps, or'default'-u username,--username=usernameβ run asusername-g groupname,--groupname=groupnameβ run asgroupname-v,--vpopmailβ enable vpopmail config-x,--nouser-configβ disable user config files-U username,--default-user=usernameβ fall back to this username if spamc user is not found (default:nobody)-D,--debug[=areas]β print debugging messages (forareas)-L,--localβ use local tests only (no DNS)-P,--paranoidβ die upon user errors-H [dir],--helper-home-dir[=dir]β specify a differentHOMEdirectory--sslβ enable SSL on TCP connections--ssl-verifyβ request a client certificate and verify it--ssl-ca-file cafileβ Certificate Authority certificate file--ssl-ca-path capathβ Certificate Authority directory--ssl-port portβ override--portsetting for SSL connections--server-key keyfileβ specify an SSL keyfile--server-cert certfileβ specify an SSL certificate--socketpath=pathβ listen on a given UNIX domain socket--socketowner=nameβ set UNIX domain socket file's owner--socketgroup=nameβ set UNIX domain socket file's group--socketmode=modeβ set UNIX domain socket file's mode--timingβ enable timing and logging-V,--versionβ print version and exit
okay now the --listen tea, because she has Lore π
the --listen option (or -i) can be specified multiple times, and her syntax is:
[ ssl: ] [ host-name-or-IP-address ] [ : port ]
...or an absolute path (filename) of a Unix socket. if you leave out the port it defaults to --port, or to 783. option --ssl implies a prefix 'ssl:'. an IPv6 address should be enclosed in square brackets, e.g. [::1]:783; an IPv4 address may be enclosed in square brackets but doesn't have to be. an asterisk '*' in place of a hostname implies an unspecified address ('0.0.0.0' or '::'), i.e. it binds to all interfaces. an empty option value implies '*'. the default is '--listen localhost', which binds to a loopback interface only π
π DESCRIPTION π
so the whole point of this program? it provides a daemonized version of the spamassassin executable. the goal is improving throughput performance for automated mail checking β basically she's the fast lane ποΈβ¨
she's meant to be used alongside spamc, a fast, low-overhead C client program. they're a duo, iykyk π«Ά
for more details, see the README file in the spamd directory of the SpamAssassin distribution.
Note: although spamd will check per-user config files for every message, any changes to the system-wide config files will require either restarting spamd or forcing it to reload itself via SIGHUP for the changes to take effect. so like, she's not gonna notice on her own, bestie π
Note: ifspamdreceives a SIGHUP, it internally reloads itself, which means that it will change its pid and might not restart at all if its environment changed (ie. if it can't change back into its own directory). if you plan to use SIGHUP, you should always startspamdwith the-rswitch to know its current pid. no cap, this one matters π
π OPTIONS π
okay first, the shortcut rules: options of the long form can be shortened as long as they remain unambiguous. (i.e. --dae can be used instead of --daemonize). also, boolean options (like --user-config) can be negated by adding no (--nouser-config), however, this is usually unnecessary. cute, right? β¨
-l,--allow-tellβ allow learning and forgetting (to a local Bayes database), reporting and revoking (to a remote database) byspamd. the client issues aTELLcommand to tell what type of message is being processed and whether local (learn/forget) or remote (report/revoke) databases should be updated.
Note:spamdalways trusts the username passed in, so clients could maliciously learn messages for other users. (this is not usually a concern with an SQL Bayes store, since users will typically have read-write access directly to the database, and can also usesa-learnwith the-uoption to achieve the same result.) π
-c,--create-prefsβ create user preferences files if they don't exist (default: don't). simple as that π-C path,--configpath=pathβ use the specified path for locating the distributed configuration files. this ignores the default directories (usually/usr/share/spamassassinor similar). bye default path, hello chosen path π--siteconfigpath=pathβ use the specified path for locating site-specific configuration files. this ignores the default directories (usually/etc/mail/spamassassinor similar) πΈ--cf='config line'β add additional lines of configuration directly from the command-line, parsed after the configuration files are read. multiple--cfarguments can be used, and each one counts as a separate line of configuration π¦--pre='config line'β add additional lines of.preconfiguration directly from the command-line, parsed before the configuration files are read. multiple--prearguments can be used, and each one counts as a separate line of configuration β¨-d,--daemonizeβ detach from the starting process and run in the background (daemonize). she's independent now, main character energy π-h,--helpβ print a brief help message, then exit without further action π-V,--versionβ print version information, then exit without further action π-i [ipaddress[:<port>]],--listen[=ipaddress[:<port>]]β additional alias names for this option are--listen-ipand--ip-address. tells spamd to listen on the specified IP address, and it defaults to a loopback interface, i.e.--listen localhost. if no value is specified after the switch, or if an asterisk'*'stands in place of an <ipaddress>, spamd will listen on all interfaces β this is equivalent to address'0.0.0.0'for IPv4 and to'::'for IPv6. you can also use a valid hostname, which will make spamd listen on all addresses that the name resolves to. the option may be specified multiple times. see also options-4and-6for restricting the address family to IPv4 or to IPv6. if a port is specified, it overrides the global--port(and--ssl-port) setting for this socket. an IPv6 address should be enclosed in square brackets, e.g.[::1]:783. for compatibility, square brackets on an IPv6 address may be omitted if a port number specification is also omitted π§-p port,--port=portβ optionally specifies the port number for the server to listen on (default:783) π₯
if the --ssl switch is used, and --ssl-port is not supplied, then this port will be used to accept SSL connections instead of unencrypted connections. if the --ssl switch is used, and --ssl-port is set, then unencrypted connections will be accepted on the --port at the same time as encrypted connections are accepted at --ssl-port. multitasking queen π
-q,--sql-configβ turn on SQL lookups even when per-user config files have been disabled with-x. this is useful for spamd hosts which don't have user's home directories but do want to load user preferences from an SQL database.
if your spamc client does not support sending the User: header, like exiscan, then the SQL username used will always be nobody. π
this inhibits thesetuid()behavior, so the-uoption is required. if you want thesetuid()behaviour, use-Qor--setuid-with-sqlinstead. important!! don't skip this π
--ldap-configβ turn on LDAP lookups. this is completely analog to--sql-config, only it is using an LDAP server π
like --sql-config, this disables the setuid behavior, and requires -u. if you want it, use --setuid-with-ldap instead.
-Q,--setuid-with-sqlβ turn on SQL lookups even when per-user config files have been disabled with-x, and also setuid to the user. this is useful for spamd hosts which want to load user preferences from an SQL database but also wish to support the use of-H(Helper home directories) π--setuid-with-ldapβ turn on LDAP lookups even when per-user config files have been disabled with-x, and also setuid to the user. this is again completely analog to--setuid-with-sql, only it is using an LDAP server π
okay that's the end of part one β more coming, don't go anywhere bestie π¦π
--virtual-config-dir=patternβ okay so this one tells spamd where to find per-user prefs for virtual users, and it's the bestie of the-xswitch. Thepatternis your base pattern for the directory name, and you get these escapes to play with, all of them, no skips:%uβ swapped for the full name of the current user, exactly asspamcsent it.%lβ swapped for the "local part" of the current username. Translation: if the username is an email address, this is the bit before the@.%dβ swapped for the "domain" of the current username. Same deal, this is the bit after the@.%xβ swapped for the full name of the current user asspamcsent it. But plot twist: if the resulting config directory doesn't exist, it gets replaced with the domain part so you fall back to a domain-wide default. Slay.%%β swapped for a single percent sign (%).
So like, for example? If /vhome/users/%u/spamassassin is specified and spamc sends a virtual username of jm@example.com, the directory /vhome/users/jm@example.com/spamassassin gets used. Periodt. β¨
The characters allowed in the virtual username for this path are restricted to:
A-Z a-z 0-9 - + _ . , @ =
Every other character gets replaced by underscores (_). Not me being dramatic, that's just the rule. π
This path must be a writable directory. It'll be created if it doesn't already exist. If a file calleduser_prefslives in this directory (and note β not in a.spamassassinsubdirectory!), it gets loaded as the user's preferences. The Bayes databases for that user get stored in this directory too.
Heads up bestie: this whole thing requires that -x is used, and it can't be combined with SQL- or LDAP-based configuration.
The pattern must expand to an absolute directory when spamd is running daemonized (-d).
Currently, use of this without -u is not supported. This inhibits setuid. π
-rpidfile,--pidfile=pidfile β writes the process ID of thespamdparent into the file you name with pidfile. The file gets unlinked when the parent exits. Also pls note: when you're running with the-uoption, that file has to be writable by that user. π«Ά-v,--vpopmailβ turns on vpopmail config. If you specify it with-uset to the vpopmail user, this letsspamdlook up/createuser_prefsin the vpopmail user's own maildir. This one's for the vpopmail virtual users who don't have an entry in the system/etc/passwdfile. Iconic little helper.
Currently, use of this without -u is not supported. This inhibits setuid.
-sfacility,--syslog=facility β picks the syslog facility to use (default:mail). Ifstderris specified, output gets written to stderr (genuinely useful if you're runningspamdunder thedaemontoolspackage). With a facility offile, all output goes tospamd.log. And facility is interpreted as a file name to log to if it contains any characters excepta-zand0-9.nulldisables logging completely (used internally, iykyk).
Examples, bestie, look:
spamd -s mail # use syslog, facility mail (default)
spamd -s ./mail # log to file ./mail
spamd -s stderr 2>/dev/null # log to stderr, throw messages away
spamd -s null # the same as above
spamd -s file # log to file ./spamd.log
spamd -s /var/log/spamd.log # log to file /var/log/spamd.log
If logging to a file is enabled and that log file gets rotated, thespamdserver must be restarted with aSIGHUP. (If the log file is just truncated, you don't need to, but it's still recommended. Do it anyway. Be safe. π)
Note that logging to a file does not use locking, so you cannot intermix logging from spamd and other processes into the same file. If you want to mix logging like this, use syslog instead.
If you use syslog logging, it is essential to send aSIGHUPto thespamddaemon when you restart thesyslogddaemon. (This is due to a shortcoming in Perl's syslog handling, where the disappearance of the connection tosyslogdis considered a fatal error. π)
--syslog-socket=type β specifies howspamdshould send messages tosyslogd. The type can be any of the socket types or logging mechanisms as accepted by the subroutineSys::Syslog::setlogsock(). Depending on the version ofSys::Syslogand on the underlying operating system, one of these values (or a subset of them) can be used:native,eventlog,tcp,udp,inet,unix,stream,pipe, orconsole. The valueeventlogis specific to the Win32 events logger and requires a perl moduleWin32::EventLogto be installed. For more info, go consult theSys::Syslogdocumentation. π
A historical setting --syslog-socket=none is mapped to --syslog=stderr.
Default for Windows platforms is none; otherwise the default is to try unix first, falling back to inet if perl detects errors in its unix support.
Some platforms, or versions of perl, ship with old or dysfunctional versions of the Sys::Syslog module that don't support some socket types, so you may need to set this option explicitly. If you get error messages regarding __PATH_LOG or similar spamd stuff, try changing this setting. π§
The socket typefileis used internally and should not be specified. Use the-sswitch instead.
--log-timestamp-fmt=format β this one can provide a POSIXstrftime(3)format for the timestamps included in each logged message. Each logger (stderr,file,syslog) has its own default value for a timestamp format, which applies when the--log-timestamp-fmtoption isn't given, or with--log-timestamp-fmt=default. Timestamps can be turned off by specifying an empty string with this option, e.g.--log-timestamp-fmt=''or just--log-timestamp-fmt=. Typical use:--log-timestamp-fmt='%a %b %e %H:%M:%S %Y'(gives you localized weekday and month names in thectime(3)style), or'%a, %e %b %Y %H:%M:%S %z (%Z)'for an RFC 2822 format, or maybe'%Y-%m-%d %H:%M:%S%z'for an ISO 8601 (EN 28601) format, or just'%Y%m%dT%H%M%S'. Pick your fighter. β°-uusername,--username=username β run as the named user. If this option isn't set, the default behaviour is tosetuid()to the user runningspamc, ifspamdis running as root.
Note:--username=rootis not a valid option. If specified,spamdwill exit with a fatal error on startup. Like, full stop. π
-ggroupname,--groupname=groupname β run as the named group if--usernameis being used. If this option isn't set when--usernameis used, then the primary group for the user given to--usernameis used.-x,--nouser-config,--user-configβ turns off (on) the reading of per-user configuration files (user_prefs) from the user's home directory. The default behaviour is to read per-user configuration from the user's home directory (--user-config).
Small but important: this option does not disable or otherwise influence the SQL, LDAP or Virtual Config Dir settings. It minds its own business. π
-Uusername,--default-user=username β fall back to this username if the username provided byspamcisn't found. Default isnobody, which might not exist or might not have a usable home directory β so use this setting to define a suitable user if you need one. π«Ά-Ahost,...,--allowed-ips=host,... β specify a comma-separated list of authorized hosts or networks that can connect to thisspamdinstance. Each element of the list is either a single IP address, or a range of IP addresses in address/masklength CIDR notation, or ranges of IPv4 addresses by specifying 3 or fewer octets with a trailing dot. Hostnames are not supported, only IPv4 or IPv6 addresses. This option can be specified multiple times, or can take a list of addresses separated by commas. IPv6 addresses may be (but need not be) enclosed in square brackets for consistency with option--listen. Examples, bestie:
-A 10.11.12.13 -- only allow connections from 10.11.12.13.
-A 10.11.12.13,10.11.12.14 -- only allow connections from
10.11.12.13 and 10.11.12.14.
-A 10.200.300.0/24 -- allow connections from any machine in the
range "10.200.300.*".
-A 10. -- allow connections from any machine in the range
"10.*.*.*".
-A [2001:db8::]/32,192.0.2.0/24,::1,127.0.0.0/8 -- only accept
connections from specified test networks and from localhost.
In absence of the -A option, connections are only accepted from IP address 127.0.0.1 or ::1, i.e. from localhost on a loopback interface. Safe and cozy. π
-D[area,...],--debug[area,...] β produce debugging output. If no areas are listed, all debugging information is printed. Diagnostic output can also be enabled for each area individually; area is the area of the code to instrument. For example, to produce diagnostic output onbayes,learn, anddns, use:
spamassassin -D bayes,learn,dns
Higher priority informational messages that are suitable for logging in normal circumstances are available with an area of info.
For more information about which areas (also known as channels) are available, please see the documentation at:
https://wiki.apache.org/spamassassin/DebugChannels
(the original page writes that one as C<https://wiki.apache.org/spamassassin/DebugChannels>, but you get the vibe β go read the wiki. π)
-4,--ipv4only,--ipv4-only,--ipv4β use IPv4 where applicable, do not use IPv6. This option affects a set of listen sockets (see option--listen) and disables IPv6 for DNS tests. Old school, but make it fashion. π-6β use IPv6 where applicable, do not use IPv4. This option affects a set of listen sockets (see option--listen) and disables IPv4 for DNS tests. Installing a moduleIO::Socket::IPis recommended ifspamdis expected to receive requests over IPv6. π-L,--localβ perform only local tests on all mail. In other words, skip DNS and other network tests. Works the same as the-Lflag tospamassassin(1). Introvert mode activated. π¦-P,--paranoidβ die on user errors (for the user passed fromspamc) instead of falling back to user--default-userand using the default configuration. Dramatic? Yes. Effective? Also yes. π-mnumber,--max-children=number β specifies the maximum number of children to spawn.Spamdwill spawn that number of children, then sleep in the background until a child dies, wherein it will go and spawn a new child. It's giving responsible single parent energy. π§
Incoming connections can still occur if all of the children are busy β however those connections will be queued, waiting for a free child. The minimum value is 1, the default value is 5.
heads up bestie π there's a OS specific maximum of connections that can be queued β try perl -MSocket -e'print SOMAXCONN' to find this maximum. that's just how your OS is built, no cap.
also lowkey a vibe check: if you run too many servers for the amount of free RAM available, you run the danger of hurting performance by causing a high swap load as server processes are swapped in and out continually. π like please don't do that to your poor machine.
--min-children=numberβ the minimum number of children that will be kept running. minimum value is1, default value is1. if you have lots of free RAM, you may want to increase this π«Ά--min-spare=numberβ the lower limit for the number of spare children allowed to run. a spare (a.k.a. idle) child is one that is not handling a scan request. if there are too few spare children available, a new server will be started every second or so. default value is1.--max-spare=numberβ the upper limit for the number of spare children allowed to run. if there are too many spare children, one will be killed every second or so until the number of idle children is in the desired range. default value is2.--max-conn-per-child=numberβ the maximum number of connections each child should process before dying and letting the masterspamdprocess spawn a new child. minimum value is1, default value is200. it's giving rotation β¨--round-robinβ by default,spamdwill attempt to keep a small number of "hot" child processes as busy as possible, and keep any others as idle as possible, using something similar to the Apache httpd server scaling algorithm. this is accomplished by the master process coordinating the activities of the children. this switch will disable this scaling algorithm, and the behaviour seen in the3.0.xversions will be used instead, where all processes receive an equal load and no scaling takes place. retro era π
π the timeout options π
--timeout-tcp=numberβ the number of seconds to wait for headers from a client (spamc) before closing the connection. minimum value is1, default value is30, and a value of0will disable socket timeouts completely. π«£--timeout-child=numberβ the number of seconds to wait for aspamdchild to process or check a message. minimum value is1, default value is300, and a value of0will disable child timeouts completely.
π home is where the helper is π
-Hdirectory,--helper-home-dir=directoryβ specify that external programs such as Razor, DCC, and Pyzor should have aHOMEenvironment variable set to a specific directory. the default is to use theHOMEenvironment variable setting from the shell runningspamd. by specifying no argument,spamdwill use thespamccaller's home directory instead. it's giving "come over, my config's comfy" π
π SSL era π
--sslβ accept only SSL connections on the associated port. theIO::Socket::SSLperl module must be installed, bestie, no exceptions.
if the --ssl switch is used, and --ssl-port is not supplied, then --port port will be used to accept SSL connections instead of unencrypted connections. if the --ssl switch is used, and --ssl-port is set, then unencrypted connections will be accepted on the --port, at the same time as encrypted connections are accepted at --ssl-port. multitasking icon π
--ssl-verifyβ implies--ssl. request a client certificate and verify the certificate. requires--ssl-ca-fileor--ssl-ca-path. trust but verify, periodt.--ssl-ca-file=cafileβ implies--ssl-verify. use the specified Certificate Authority certificate to verify the client certificate. the client certificate must be signed by this certificate.--ssl-ca-path=capathβ implies--ssl-verify. use the Certificate Authority certificate files in the specified set of directories to verify the client certificate. the client certificate must be signed by one of these Certificate Authorities. see the man page forIO::Socket::SSLfor additional details. iykyk πΈ--ssl-port=portβ optionally specifies the port number for the server to listen on for SSL connections (default: whatever--portuses). see--sslfor more details.--server-key keyfileβ specify the SSL key file to use for SSL connections. ποΈ--server-cert certfileβ specify the SSL certificate file to use for SSL connections. π
𧦠unix domain socket options π§¦
--socketpath pathnameβ listen on a UNIX domain socket at path pathname, in addition to sockets specified with a--listenoption. this option is provided for compatibility with older versions ofspamd. starting with version3.4.0the--listenoption can also take a UNIX domain socket as its value (an absolute path name). unlike--socketpath, the--listenoption may be specified multiple times ifspamdneeds to listen on multiple UNIX or INET or INET6 sockets.
β οΈ warning, bestie, this one's a whole thing: the Perl support on BSD platforms for UNIX domain sockets seems to have a bug regarding paths of over 100 bytes or so (SpamAssassin bug4380). if you see a'could not find newly-created UNIX socket'error message, and the path appears truncated, this may be the cause. try using a shorter path to the socket. π
by default, use of --socketpath without --listen will inhibit SSL connections and unencrypted TCP connections. to add other sockets, specify them with --listen, e.g. '--listen=:' or '--listen=*:'
--socketowner nameβ set UNIX domain socket to be owned by the user named name. note that this requires thatspamdbe started asroot, and if-uis used, that user should have write permissions to unlink the file later, for when thespamdserver is killed. π--socketgroup nameβ set UNIX domain socket to be owned by the group named name. see--socketownerfor notes on ownership and permissions.--socketmode modeβ set UNIX domain socket to use the octal mode mode. note that if-uis used, that user should have write permissions to unlink the file later, for when thespamdserver is killed.
--timingβ enable timing measurements and output the information for logging. this is the same information as provided by theTIMINGtag. β±οΈ honestly kinda obsessed with how much this tells you.
π SEE ALSO π
spamc(1) spamassassin(1) Mail::SpamAssassin::Conf(3) Mail::SpamAssassin(3)
go read those too, they're the supporting cast and they ate π
β¨ PREREQUISITES β¨
Mail::SpamAssassin
that's the whole list. one prerequisite. main character energy fr fr.
π AUTHORS π
The SpamAssassin(tm) Project (https://spamassassin.apache.org/)
π LICENSE π
SpamAssassin is distributed under the Apache License, Version 2.0, as described in the file LICENSE included with the distribution. π«Ά read it, it's right there.
and that's the whole page, bestie β no crumbs left π¦ this drop is perl v5.42.0, dated 2025-08-31, and it lives at SPAMD(1). mwah, go scan some mail πβ¨π
π¦ where this page comes from
- alpine 3.23: spamassassin-doc 4.0.2-r0 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms