SPAMC(1)
π NAME π
spamc β client for spamd π
β¨
β¨ SYNOPSIS β¨
spamc [options] < message
πΈ DESCRIPTION πΈ
Okay bestie, so spamc is literally the client half of the spamc/spamd pair π«Ά. You use it in place of spamassassin in scripts to process mail. It reads the mail from STDIN, spools it over to its connection to spamd, then reads the result back and prints it to STDOUT. And the way it has extremely low overhead in loading? Obsessed π β it should be much faster to load than the whole spamassassin program, fr fr.
See the README file in the spamd directory of the SpamAssassin distribution for more details π.
π OPTIONS π
All options detailed below can be passed as command line arguments, or be contained in a configuration file, as described in the CONFIGURATION FILE section below. Lowkey important: the long options, a la --long-options, are new as of SpamAssassin 3.2.0, and were not available in earlier versions π.
-B,--bsmtpβ Assume input is a single BSMTP-formatted message. In other words,spamcwill pull out everything between theDATAline and the lone-dot line to feed tospamd, and will place thespamdoutput back in the same envelope (thus, anySIZEextension in your BSMTP file will cause many problems π).-c,--checkβ Just check if the message is spam or not. Set process exitcode to1if message is spam,0if not spam or processing failure occurs. Will print score/threshold to stdout (as ints) or0/0if there was an error. Combining-cand-Eis a no-op, since-cimplies the behaviour of-Eβ¨.-d host[,host2],--dest=host[,host2]β In TCP/IP mode, connect tospamdserver on given host (default:localhost). Several hosts can be specified if separated by commas π«.
If host resolves to multiple addresses, then spamc will fail-over to the other addresses, if the first one cannot be connected to. It will first try all addresses of one host before it tries the next one in the list. Note that this fail-over behaviour is incompatible with -x; if that switch is used, fail-over will not occur π« .
-4β Use IPv4 only for connecting to server. Restricts domain name resolution ofspamdserver host(s) to address familyAF_INETthrough thehints.ai_familyflag in the call togetaddrinfo(3)π.-6β Use IPv6 only for connecting to server. Restricts domain name resolution ofspamdserver host(s) to address familyAF_INET6through thehints.ai_familyflag in the call togetaddrinfo(3)π.-e command [args],--pipe-to command [args]β Instead of writing to stdout, pipe the output to command's standard input. Note that there is a very slight chance mail will be lost here, because if the fork-and-exec fails there's no place to put the mail message π.
Note that this must be the LAST command line option, as everything after the -e is taken as arguments to the command (it's like rxvt or xterm) π
.
This option is not supported on Win32 platforms π.
-E,--exitcodeβ Filter according to the other options, but set the process exitcode to1if message is spam,0if not spam or processing failure occurs β¨.-F /path/to/file,--config=pathβ Specify a configuration file to read additional command-line flags from. See CONFIGURATION FILE below π.-h,--helpβ Print this help message and terminate without action π.-H,--randomizeβ For TCP/IP sockets, randomize the IP addresses returned for the hosts given by the-dswitch. This provides for a simple kind of load balancing. It will try only three times though π.-l,--log-to-stderrβ Send log messages to stderr, instead of to the syslog πΈ.-L learn type,--learntype=typeβ Send message tospamdfor learning. The "learn type" can be eitherspam,hamorforget. The exitcode forspamcwill be set to0if the message was learned or if it had already been learned. Non-zero exitcodes indicate an actual failure of some sort π.
Note that the spamd must run with the --allow-tell option for this to work π.
-C report type,--reporttype=typeβ Report or revoke a message to one of the configured collaborative filtering databases. The "report type" can be eitherreportorrevokeπ¦.
Note that the spamd must run with the --allow-tell option for this to work π.
-p port,--port=portβ In TCP/IP mode, connect tospamdserver listening on given port (default:783) π₯.-r,--full-spamβ Just output the SpamAssassin report text to stdout, if the message is spam. If the message is ham (non-spam), nothing will be printed. The first line of the output is the message score and the threshold, in this format:
score/threshold
-R,--fullβ Just output the SpamAssassin report text to stdout, for all messages. See-rfor details of the output format used π.-s max_size,--max-size=max_sizeβ Set the maximum message size which will be sent tospamdβ any bigger than this threshold and the message will be returned unprocessed (default:500 KB). Ifspamcgets handed a message bigger than this, it won't be passed tospamd. The maximum message size is256 MBβ.
The size is specified in bytes, as a positive integer greater than 0. For example, -s 500000.
--connect-retries=retriesβ Retry connecting tospamdretriestimes. The default is3times π.--retry-sleep=sleepβ Sleep forsleepseconds between attempts to connect tospamd. The default is1second π΄.--filter-retries=retriesβ Retry filteringretriestimes if thespamdprocess fails (usually times out). This differs from--connect-retriesin that it times out the transaction after the TCP connection has been established successfully. The default is1time (ie. one attempt and no retries) π«Ά.--filter-retry-sleep=sleepβ Sleep forsleepseconds between failedspamdfiltering attempts. The default is1second π΄.-S,--sslβ Ifspamcwas built with support for SSL, encrypt data to and from thespamdprocess with SSL;spamdmust support SSL as well πβ¨.--ssl-cert=certfileβ Authenticate tospamdserver with a SSL client certificate. Specify the certificate file to use π.--ssl-key=keyfileβ Authenticate tospamdserver with a SSL client certificate. Specify the certificate key file to use ποΈ.--ssl-ca-file=cafileβ Use the specified Certificate Authority certificate to verify the server certificate. The server certificate must be signed by this certificate π.--ssl-ca-path=capathβ Use the Certificate Authority certificate files in the specified set of directories to verify the server certificate. The server certificate must be signed by one of these Certificate Authorities. See the man page forIO::Socket::SSLfor additional details π.-t timeout,--timeout=timeoutβ Set the timeout forspamc-to-spamdcommunications (default:600,0disables). Ifspamdtakes longer than this many seconds to reply to a message,spamcwill abort the connection and treat this as a failure to connect; in other words the message will be returned unprocessed π.-n timeout,--connect-timeout=timeoutβ Set the timeout forspamc-to-spamdconnection establishment (default:600,0disables). Ifspamctakes longer than this many seconds to establish a connection tospamd,spamcwill abort the connection and treat this as a failure to connect; in other words the message will be returned unprocessed π.-u username,--username=usernameβ To havespamduse per-user-config files, runspamcas the user whose config filesspamdshould load; by default the effective user-ID is sent tospamd. If you're runningspamcas some other user, though, (eg.root,mail,nobody,cyrus, etc.) then you may use this flag to override the default π .-U socketpath,--socket=pathβ Connect tospamdvia UNIX domain socketsocketpathinstead of a TCP/IP connection π§.
This option is not supported on Win32 platforms π.
-V,--versionβ Report the version of thisspamcclient. If built with SSL support, an additional line will be included noting this, like so:
SpamAssassin Client version 3.0.0-rc4
compiled with SSL support (OpenSSL 0.9.7d 17 Mar 2004)
-x,--no-safe-fallbackβ Disables the 'safe fallback' error-recovery method, which passes through the unaltered message if an error occurs. Instead, exit with an error code, and let the MTA queue up the mails for a retry later. See also "EXIT CODES" π.
This also disables the TCP fail-over behaviour from -d π« .
-X,--unavailable-tempfailβ When disabling 'safe fallback' with-x, this option will turnEX_UNAVAILABLEerrors intoEX_TEMPFAIL. This may allow your MTA to defer mails with a temporary SMTP error instead of bouncing them with a permanent SMTP error. See also "EXIT CODES" β.-y,--testsβ Just output the names of the tests hit to stdout, on one line, separated by commas πΈ.-Kβ Perform a keep-alive check ofspamd, instead of a full message check π.-zβ Use gzip compression to compress the mail message sent tospamd. This is useful for long-distance use ofspamcover the internet. Note that this relies onzlibbeing installed on thespamcclient side, and theCompress::Zlibperl module on the server side; an error will be returned otherwise π.--headersβ Perform a scan, but instead of allowing any part of the message (header and body) to be rewritten, limit rewriting to only the message headers. This is much more efficient in bandwidth usage, since the response message transmitted back from thespamdserver will not include the body π.
Note that this only makes sense if you are using report_safe 0 in the scanning configuration on the remote end; with report_safe 1, it is likely to result in corrupt messages π.
π CONFIGURATION FILE π
okay so bestie, plot twist: all those command-line switches up there? they can also be loaded from a configuration file. no cap. π«Ά
The format of the file is similar to the SpamAssassin rules files; blank lines and lines beginning with # are ignored. Any space-separated words are considered additions to the command line, and are prepended. Newlines are treated as equivalent to spaces. Existing command line switches will override any settings in the configuration file. iykyk β command line stays main character. π
If the -F switch is specified, that file will be used. Otherwise, spamc will attempt to load spamc.conf in SYSCONFDIR (default: /etc/mail/spamassassin). If that file doesn't exist, and the -F switch is not specified, no configuration file will be read. periodt. β¨
Example:
# spamc global configuration file
# connect to "server.example.com", port 783
-d server.example.com
-p 783
# max message size for scanning = 350k
-s 350000
π EXIT CODES π
By default, spamc will use the 'safe fallback' error recovery method. That means it will always exit with an exit code of 0, even if an error was encountered. If any error occurs, it will simply pass through the unaltered message. lowkey chaotic, but that's the default. π
The -c and -E options modify this; instead, spamc will use an exit code of 1 if the message is determined to be spam. π₯
If one of the -x, -L or -C options are specified, 'safe fallback' will be disabled, and certain error conditions related to communication between spamc and spamd will result in an error code. vibe check: those flags change the whole exit-code situation. π
The exit codes used are as follows:
EX_USAGE 64 command line usage error
EX_DATAERR 65 data format error
EX_NOINPUT 66 cannot open input
EX_NOUSER 67 addressee unknown
EX_NOHOST 68 host name unknown
EX_UNAVAILABLE 69 service unavailable
EX_SOFTWARE 70 internal software error
EX_OSERR 71 system error (e.g., can't fork)
EX_OSFILE 72 critical OS file missing
EX_CANTCREAT 73 can't create (user) output file
EX_IOERR 74 input/output error
EX_TEMPFAIL 75 temp failure; user is invited to retry
EX_PROTOCOL 76 remote error in protocol
EX_NOPERM 77 permission denied
EX_CONFIG 78 configuration error
* The EX_TOOBIG error level is never used. If spamc receives a message
that is too big, the exit code will be 0.
EX_TOOBIG 98 message was too big to process (see --max-size)
β οΈ heads up, bestie: theEX_TOOBIGerror level is never used. Ifspamcreceives a message that is too big, the exit code will be0. the original page also puts theEX_TOOBIGline after that note, so don't let the order jump-scare you. π
π SEE ALSO π
spamd(1) spamassassin(1) Mail::SpamAssassin(3)
they're all right there in the references, periodt. π
πΈ PREREQUISITES πΈ
Mail::SpamAssassin
that's the prerequisite, no extra lore needed. π¦
π AUTHORS π
The SpamAssassin(tm) Project <https://spamassassin.apache.org/>
iconic authorship moment. β
π COPYRIGHT π
SpamAssassin is distributed under the Apache License, Version 2.0, as described in the file LICENSE included with the distribution. legal text ate, no notes. π
okay that's the whole page, bestie! this SPAMC(1) moment was rendered with perl v5.44.0 and dated 2026-10-18 β bye, love u, happy scanning ππ¦β¨
π¦ where this page comes from
- arch rolling: spamassassin 4.0.2-3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms