1SPAMC(1)              User Contributed Perl Documentation             SPAMC(1)
2
3
4

NAME

6       spamc - client for spamd
7

SYNOPSIS

9       spamc [options] < message
10

DESCRIPTION

12       Spamc is the client half of the spamc/spamd pair.  It should be used in
13       place of "spamassassin" in scripts to process mail.  It will read the
14       mail from STDIN, and spool it to its connection to spamd, then read the
15       result back and print it to STDOUT.  Spamc has extremely low overhead
16       in loading, so it should be much faster to load than the whole
17       spamassassin program.
18
19       See the README file in the spamd directory of the SpamAssassin
20       distribution for more details.
21

OPTIONS

23       All options detailed below can be passed as command line arguments, or
24       be contained in a configuration file, as described in the CONFIGURATION
25       FILE section below.
26
27       Note that the long options, a la "--long-options", are new as of
28       SpamAssassin 3.2.0, and were not available in earlier versions.
29
30       -B, --bsmtp
31           Assume input is a single BSMTP-formatted message. In other words,
32           spamc will pull out everything between the DATA line and the lone-
33           dot line to feed to spamd, and will place the spamd output back in
34           the same envelope (thus, any SIZE extension in your BSMTP file will
35           cause many problems).
36
37       -c, --check
38           Just check if the message is spam or not.  Set process exitcode to
39           1 if message is spam, 0 if not spam or processing failure occurs.
40           Will print score/threshold to stdout (as ints) or 0/0 if there was
41           an error.  Combining -c and -E is a no-op, since -c implies the
42           behaviour of -E.
43
44       -d host[,host2], --dest=host[,host2]
45           In TCP/IP mode, connect to spamd server on given host (default:
46           localhost).  Several hosts can be specified if separated by commas.
47
48           If host resolves to multiple addresses, then spamc will fail-over
49           to the other addresses, if the first one cannot be connected to.
50           It will first try all addresses of one host before it tries the
51           next one in the list.  Note that this fail-over behaviour is
52           incompatible with -x; if that switch is used, fail-over will not
53           occur.
54
55       -4  Use IPv4 only for connecting to server. Restricts domain name
56           resolution of spamd server host(s) to address family AF_INET
57           through the "hints.ai_family" flag in the call to getaddrinfo(3).
58
59       -6  Use IPv6 only for connecting to server. Restricts domain name
60           resolution of spamd server host(s) to address family AF_INET6
61           through the "hints.ai_family" flag in the call to getaddrinfo(3).
62
63       -e command [args], --pipe-to command [args]
64           Instead of writing to stdout, pipe the output to command's standard
65           input.  Note that there is a very slight chance mail will be lost
66           here, because if the fork-and-exec fails there's no place to put
67           the mail message.
68
69           Note that this must be the LAST command line option, as everything
70           after the -e is taken as arguments to the command (it's like rxvt
71           or xterm).
72
73           This option is not supported on Win32 platforms.
74
75       -E, --exitcode
76           Filter according to the other options, but set the process exitcode
77           to 1 if message is spam, 0 if not spam or processing failure
78           occurs.
79
80       -F /path/to/file, --config=path
81           Specify a configuration file to read additional command-line flags
82           from.  See CONFIGURATION FILE below.
83
84       -h, --help
85           Print this help message and terminate without action.
86
87       -H, --randomize
88           For TCP/IP sockets, randomize the IP addresses returned for the
89           hosts given by the -d switch. This provides for a simple kind of
90           load balancing.  It will try only three times though.
91
92       -l, --log-to-stderr
93           Send log messages to stderr, instead of to the syslog.
94
95       -L learn type, --learntype=type
96           Send message to spamd for learning.  The "learn type" can be either
97           spam, ham or forget.  The exitcode for spamc will be set to 5 if
98           the message was learned, or 6 if it was already learned, under a
99           condition that a --no-safe-fallback option is selected too.
100
101           Note that the "spamd" must run with the "--allow-tell" option for
102           this to work.
103
104       -C report type, --reporttype=type
105           Report or revoke a message to one of the configured collaborative
106           filtering databases.  The "report type" can be either report or
107           revoke.
108
109           Note that the "spamd" must run with the "--allow-tell" option for
110           this to work.
111
112       -p port, --port=port
113           In TCP/IP mode, connect to spamd server listening on given port
114           (default: 783).
115
116       -r, --full-spam
117           Just output the SpamAssassin report text to stdout, if the message
118           is spam.  If the message is ham (non-spam), nothing will be
119           printed.  The first line of the output is the message score and the
120           threshold, in this format:
121
122                   score/threshold
123
124       -R, --full
125           Just output the SpamAssassin report text to stdout, for all
126           messages.  See -r for details of the output format used.
127
128       -s max_size, --max-size=max_size
129           Set the maximum message size which will be sent to spamd -- any
130           bigger than this threshold and the message will be returned
131           unprocessed (default: 500 KB).  If spamc gets handed a message
132           bigger than this, it won't be passed to spamd.  The maximum message
133           size is 256 MB.
134
135           The size is specified in bytes, as a positive integer greater than
136           0.  For example, -s 500000.
137
138       --connect-retries=retries
139           Retry connecting to spamd retries times.  The default is 3 times.
140
141       --retry-sleep=sleep
142           Sleep for sleep seconds between attempts to connect to spamd.  The
143           default is 1 second.
144
145       --filter-retries=retries
146           Retry filtering retries times if the spamd process fails (usually
147           times out).  This differs from --connect-retries in that it times
148           out the transaction after the TCP connection has been established
149           successfully.  The default is 1 time (ie. one attempt and no
150           retries).
151
152       --filter-retry-sleep=sleep
153           Sleep for sleep seconds between failed spamd filtering attempts.
154           The default is 1 second.
155
156       -S, --ssl
157           If spamc was built with support for SSL, encrypt data to and from
158           the spamd process with SSL; spamd must support SSL as well.
159
160       --ssl-cert=certfile
161           Authenticate to spamd server with a SSL client certificate.
162           Specify the certificate file to use.
163
164       --ssl-key=keyfile
165           Authenticate to spamd server with a SSL client certificate.
166           Specify the certificate key file to use.
167
168       --ssl-ca-file=cafile
169           Use the specified Certificate Authority certificate to verify the
170           server certificate.  The server certificate must be signed by this
171           certificate.
172
173       --ssl-ca-path=capath
174           Use the Certificate Authority certificate files in the specified
175           set of directories to verify the server certificate.  The server
176           certificate must be signed by one of these Certificate Authorities.
177           See the man page for IO::Socket::SSL for additional details.
178
179       -t timeout, --timeout=timeout
180           Set the timeout for spamc-to-spamd communications (default: 600, 0
181           disables).  If spamd takes longer than this many seconds to reply
182           to a message, spamc will abort the connection and treat this as a
183           failure to connect; in other words the message will be returned
184           unprocessed.
185
186       -n timeout, --connect-timeout=timeout
187           Set the timeout for spamc-to-spamd connection establishment
188           (default: 600, 0 disables). If spamc takes longer than this many
189           seconds to establish a connection to spamd, spamc will abort the
190           connection and treat this as a failure to connect; in other words
191           the message will be returned unprocessed.
192
193       -u username, --username=username
194           To have spamd use per-user-config files, run spamc as the user
195           whose config files spamd should load; by default the effective
196           user-ID is sent to spamd.  If you're running spamc as some other
197           user, though, (eg. root, mail, nobody, cyrus, etc.) then you may
198           use this flag to override the default.
199
200       -U socketpath, --socket=path
201           Connect to "spamd" via UNIX domain socket socketpath instead of a
202           TCP/IP connection.
203
204           This option is not supported on Win32 platforms.
205
206       -V, --version
207           Report the version of this "spamc" client.  If built with SSL
208           support, an additional line will be included noting this, like so:
209
210             SpamAssassin Client version 3.0.0-rc4
211               compiled with SSL support (OpenSSL 0.9.7d 17 Mar 2004)
212
213       -x, --no-safe-fallback
214           Disables the 'safe fallback' error-recovery method, which passes
215           through the unaltered message if an error occurs.  Instead, exit
216           with an error code, and let the MTA queue up the mails for a retry
217           later.  See also "EXIT CODES".
218
219           This also disables the TCP fail-over behaviour from -d.
220
221       -X, --unavailable-tempfail
222           When disabling 'safe fallback' with -x, this option will turn
223           EX_UNAVAILABLE errors into EX_TEMPFAIL. This may allow your MTA to
224           defer mails with a temporary SMTP error instead of bouncing them
225           with a permanent SMTP error.  See also "EXIT CODES".
226
227       -y, --tests
228           Just output the names of the tests hit to stdout, on one line,
229           separated by commas.
230
231       -K  Perform a keep-alive check of spamd, instead of a full message
232           check.
233
234       -z  Use gzip compression to compress the mail message sent to "spamd".
235           This is useful for long-distance use of spamc over the internet.
236           Note that this relies on "zlib" being installed on the "spamc"
237           client side, and the "Compress::Zlib" perl module on the server
238           side; an error will be returned otherwise.
239
240       --headers
241           Perform a scan, but instead of allowing any part of the message
242           (header and body) to be rewritten, limit rewriting to only the
243           message headers. This is much more efficient in bandwidth usage,
244           since the response message transmitted back from the spamd server
245           will not include the body.
246
247           Note that this only makes sense if you are using "report_safe 0" in
248           the scanning configuration on the remote end; with "report_safe 1",
249           it is likely to result in corrupt messages.
250

CONFIGURATION FILE

252       The above command-line switches can also be loaded from a configuration
253       file.
254
255       The format of the file is similar to the SpamAssassin rules files;
256       blank lines and lines beginning with "#" are ignored.  Any space-
257       separated words are considered additions to the command line, and are
258       prepended. Newlines are treated as equivalent to spaces. Existing
259       command line switches will override any settings in the configuration
260       file.
261
262       If the -F switch is specified, that file will be used.  Otherwise,
263       "spamc" will attempt to load spamc.conf in "SYSCONFDIR" (default:
264       /etc/mail/spamassassin). If that file doesn't exist, and the -F switch
265       is not specified, no configuration file will be read.
266
267       Example:
268
269           # spamc global configuration file
270
271           # connect to "server.example.com", port 783
272           -d server.example.com
273           -p 783
274
275           # max message size for scanning = 350k
276           -s 350000
277

EXIT CODES

279       By default, spamc will use the 'safe fallback' error recovery method.
280       That means, it will always exit with an exit code of 0, even if an
281       error was encountered.  If any error occurs, it will simply pass
282       through the unaltered message.
283
284       The -c and -E options modify this; instead, spamc will use an exit code
285       of 1 if the message is determined to be spam.
286
287       If one of the "-x", "-L" or "-C" options are specified, 'safe fallback'
288       will be disabled, and certain error conditions related to communication
289       between spamc and spamd will result in an error code.
290
291       The exit codes used are as follows:
292
293           EX_USAGE        64  command line usage error
294           EX_DATAERR      65  data format error
295           EX_NOINPUT      66  cannot open input
296           EX_NOUSER       67  addressee unknown
297           EX_NOHOST       68  host name unknown
298           EX_UNAVAILABLE  69  service unavailable
299           EX_SOFTWARE     70  internal software error
300           EX_OSERR        71  system error (e.g., can't fork)
301           EX_OSFILE       72  critical OS file missing
302           EX_CANTCREAT    73  can't create (user) output file
303           EX_IOERR        74  input/output error
304           EX_TEMPFAIL     75  temp failure; user is invited to retry
305           EX_PROTOCOL     76  remote error in protocol
306           EX_NOPERM       77  permission denied
307           EX_CONFIG       78  configuration error
308
309           * The EX_TOOBIG error level is never used.  If spamc receives a message
310             that is too big, the exit code will be 0.
311
312           EX_TOOBIG       98  message was too big to process (see --max-size)
313

SEE ALSO

315       spamd(1) spamassassin(1) Mail::SpamAssassin(3)
316

PREREQUISITES

318       "Mail::SpamAssassin"
319

AUTHORS

321       The SpamAssassin(tm) Project <https://spamassassin.apache.org/>
322
324       SpamAssassin is distributed under the Apache License, Version 2.0, as
325       described in the file "LICENSE" included with the distribution.
326
327
328
329perl v5.36.0                      2023-01-21                          SPAMC(1)
Impressum