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, --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       -t timeout, --timeout=timeout
161           Set the timeout for spamc-to-spamd communications (default: 600, 0
162           disables).  If spamd takes longer than this many seconds to reply
163           to a message, spamc will abort the connection and treat this as a
164           failure to connect; in other words the message will be returned
165           unprocessed.
166
167       -n timeout, --connect-timeout=timeout
168           Set the timeout for spamc-to-spamd connection establishment
169           (default: 600, 0 disables). If spamc takes longer than this many
170           seconds to establish a connection to spamd, spamc will abort the
171           connection and treat this as a failure to connect; in other words
172           the message will be returned unprocessed.
173
174       -u username, --username=username
175           To have spamd use per-user-config files, run spamc as the user
176           whose config files spamd should load; by default the effective
177           user-ID is sent to spamd.  If you're running spamc as some other
178           user, though, (eg. root, mail, nobody, cyrus, etc.) then you may
179           use this flag to override the default.
180
181       -U socketpath, --socket=path
182           Connect to "spamd" via UNIX domain socket socketpath instead of a
183           TCP/IP connection.
184
185           This option is not supported on Win32 platforms.
186
187       -V, --version
188           Report the version of this "spamc" client.  If built with SSL
189           support, an additional line will be included noting this, like so:
190
191             SpamAssassin Client version 3.0.0-rc4
192               compiled with SSL support (OpenSSL 0.9.7d 17 Mar 2004)
193
194       -x, --no-safe-fallback
195           Disables the 'safe fallback' error-recovery method, which passes
196           through the unaltered message if an error occurs.  Instead, exit
197           with an error code, and let the MTA queue up the mails for a retry
198           later.  See also "EXIT CODES".
199
200           This also disables the TCP fail-over behaviour from -d.
201
202       -X, --unavailable-tempfail
203           When disabling 'safe fallback' with -x, this option will turn
204           EX_UNAVAILABLE errors into EX_TEMPFAIL. This may allow your MTA to
205           defer mails with a temporary SMTP error instead of bouncing them
206           with a permanent SMTP error.  See also "EXIT CODES".
207
208       -y, --tests
209           Just output the names of the tests hit to stdout, on one line,
210           separated by commas.
211
212       -K  Perform a keep-alive check of spamd, instead of a full message
213           check.
214
215       -z  Use gzip compression to compress the mail message sent to "spamd".
216           This is useful for long-distance use of spamc over the internet.
217           Note that this relies on "zlib" being installed on the "spamc"
218           client side, and the "Compress::Zlib" perl module on the server
219           side; an error will be returned otherwise.
220
221       --headers
222           Perform a scan, but instead of allowing any part of the message
223           (header and body) to be rewritten, limit rewriting to only the
224           message headers. This is much more efficient in bandwidth usage,
225           since the response message transmitted back from the spamd server
226           will not include the body.
227
228           Note that this only makes sense if you are using "report_safe 0" in
229           the scanning configuration on the remote end; with "report_safe 1",
230           it is likely to result in corrupt messages.
231

CONFIGURATION FILE

233       The above command-line switches can also be loaded from a configuration
234       file.
235
236       The format of the file is similar to the SpamAssassin rules files;
237       blank lines and lines beginning with "#" are ignored.  Any space-
238       separated words are considered additions to the command line, and are
239       prepended. Newlines are treated as equivalent to spaces. Existing
240       command line switches will override any settings in the configuration
241       file.
242
243       If the -F switch is specified, that file will be used.  Otherwise,
244       "spamc" will attempt to load spamc.conf in "SYSCONFDIR" (default:
245       /etc/mail/spamassassin). If that file doesn't exist, and the -F switch
246       is not specified, no configuration file will be read.
247
248       Example:
249
250           # spamc global configuration file
251
252           # connect to "server.example.com", port 783
253           -d server.example.com
254           -p 783
255
256           # max message size for scanning = 350k
257           -s 350000
258

EXIT CODES

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

SEE ALSO

296       spamd(1) spamassassin(1) Mail::SpamAssassin(3)
297

PREREQUISITES

299       "Mail::SpamAssassin"
300

AUTHORS

302       The SpamAssassin(tm) Project <https://spamassassin.apache.org/>
303
305       SpamAssassin is distributed under the Apache License, Version 2.0, as
306       described in the file "LICENSE" included with the distribution.
307
308
309
310perl v5.34.0                      2021-07-23                          SPAMC(1)
Impressum