1393 |
--------------------------------------------------------------------------------
/previous-versions/spampd.1.0.1.pl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mpaperno/spampd/b023c3b5ca372060904faa7cc051902430d05a02/previous-versions/spampd.1.0.1.pl
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | [](https://github.com/mpaperno/spampd/releases)
2 | [](https://github.com/mpaperno/spampd/blob/master/spampd.pod)
3 | [](LICENSE.txt)
4 |
5 | # SpamPD - Spam Proxy Daemon
6 |
7 | Originally released in May of 2002, _SpamPD_ is a program used within an e-mail delivery system to scan messages for possible Unsolicited Commercial E-mail (UCE, aka spam) content.
8 | It uses an excellent program called SpamAssassin (SA) to do the actual message scanning. SpamPD acts as a transparent SMTP/LMTP proxy between
9 | two mail servers, and during the transaction it passes the mail through SA. If SA decides the mail could be spam, then SpamPD will ask SA to
10 | add some headers and a report to the message indicating it's spam and why.
11 |
12 | SpamPD is written in Perl and should theoretically run on any platform supported by Perl and SpamAssassin.
13 |
14 | Here's an un-solicited comment someone sent regarding *SpamPD* performance:
15 |
16 | > Just to let you know: We have the SA/spampd combo up an running in a high volume environment. With 3 KAT-B Server (4x 2,5 GHz Xeon MP
17 | with Hyperthreading, 3 GB RAM) we handle 15.000 to 20.000 Mails/h (Hour!) with room to spare. We had some performance issues with the
18 | Bayes databases but now everything runs smoothly.
19 |
20 | Check the [Releases](https://github.com/mpaperno/spampd/releases) area for latest versions,
21 | and see the "previous-versions" folder for some more ancient ones.
22 | (Note that the Debian package version was added to this repo as a branch, and those tags will also show up in the Releases page.)
23 |
24 | Please read the [POD file](https://github.com/mpaperno/spampd/blob/master/spampd.pod) for full documentation of the many available options.
25 | See the [changelog](https://github.com/mpaperno/spampd/blob/master/changelog.txt) for full version history.
26 |
27 | ## Package status
28 |
29 |
30 |
31 |
32 |
33 | **HELP!** Debian package maintainer needed. Please see [GitHub Issue 46](https://github.com/mpaperno/spampd/issues/46).
34 |
35 | Linux packages data at right courtesy of Repology:
36 |
37 |
38 | Usage
39 | SpamPD was initially designed as a content filter mechanism for use with the Postfix MTA.
40 | However, it has no inherent dependencies on Postfix or any other MTA.
41 | Some more specific setup information is provided in the included documentation.
42 |
43 | Version 2 Architecture
44 | Version 2 of SpamPD is a major rewrite of the underlying methods. SpamPD
45 | no longer acts as a relay server but more as a "transparent" proxy
46 | server. That is, it never actually takes responsibility for the mail at
47 | any point. Instead, the origination and destination mail servers speak
48 | directly to each other. If a failure occurs within SpamPD
49 | (or SpamAssassin) during a transaction, then the mail servers will
50 | disconnect and the sending server is still responsible for retrying the
51 | message for as long as it is configured to do so. Responsibility for
52 | mail delivery always lies with the 2 mail servers, which would be "real"
53 | MTAs and not a 500 line Perl script :-) This removes a major problem
54 | with version 1 of SpamPD, and makes this a recommended upgrade.
55 | While this is a much safer technique than previously employed, it does remove a possible feature which some users of SpamPD
56 | have implemented (sorry guys). That is redirecting spam to a spamtrap
57 | address instead of letting the message through to the original
58 | recipient. This is due to the fact that the recipient information is
59 | passed on to the destination server before the message data is scanned
60 | for spam. On the other hand it presents the possibility of rejecting
61 | spam at the S/LMTP level without having to generate bounce notices and
62 | such.
63 |
64 | SpamPD now fully supports the LMTP
65 | protocol (due to the nature of it's new transparency). Logging has been
66 | improved and is now more compatible with spamd
.
67 | New parameters added: --children, --local-only, --childtimeout,
68 | --satimeout, --dose, --log-rules-hit, --add-sc-header, and --hostname.
69 | Three parameters are now deprecated: --dead-letters, --heloname, and
70 | --stop-at-threshold.
71 | More details and further changes are documented in the change log.
72 |
73 | More Information
74 |
75 | If you aren't familiar with SpamAssassin,
76 | then you should definitely start there (or end up there) first. There
77 | is a very helpful users discussion list for SA (see their site). For Postfix setup, be sure to read the FILTER_README document that is included with the distribution. SpamPD is meant to be used as an "advanced content filtering" method (some examples are included with the SpamPD
78 | documentation). Postfix also has a helpful users discussion list. Make
79 | sure you do your homework before you ask other people to help you!
80 |
81 | Be sure to check out the SpamPD documentation, the change log, as well as comments in the actual code.
82 |
83 | Credits
84 | SpamPD is written and maintained by Maxim Paperno (https://github.com/mpaperno).
85 | SpamPD contains code written by
86 | Bennecode Todd (Copyright (C) 2001 Morgan Stanley Dean Witter) and is used
87 | in accordance with the GNU General Public License. The code is in the
88 | form of two Perl modules which have been included in the program. Also
89 | his smtpproxy
example program served as inspiration for this version of SpamPD.
90 | SpamPD version 1 was based on code by Dave Carrigan named assassind
. Trace amounts of his code or documentation may still remain. Thanks to him for the original inspiration and code.
91 | Various people have contributed patches, bug reports, and ideas, all
92 | of whom I would like to thank. I have tried to include credits in code
93 | comments, documentation, and in the change log, as appropriate.
94 |
95 | Copyright, License, & Disclaimer
96 | Copyright Maxim Paperno; All rights reserved.
97 | Portions are Copyright © 2001 Morgan Stanley Dean Witter as mentioned above in the CREDITS section.
98 | This program is free software; you can redistribute it and/or modify
99 | it under the terms of the GNU General Public License as published by the
100 | Free Software Foundation; either version 2 of the License, or (at your
101 | option) any later version.
102 | This program is distributed in the hope that it will be useful, but
103 | WITHOUT ANY WARRANTY; without even the implied warranty of
104 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
105 | Public License for more details.
106 | The GNU GPL can be found at https://www.gnu.org/licenses/
107 |
--------------------------------------------------------------------------------
/spampd.pod:
--------------------------------------------------------------------------------
1 | =encoding UTF-8
2 |
3 | =head1 NAME
4 |
5 | SpamPD - Spam Proxy Daemon
6 |
7 | =head1 VERSION
8 |
9 | Documentation for SpamPD version 2.62.
10 |
11 |
12 | =head1 DESCRIPTION
13 |
14 | I is an SMTP/LMTP proxy that marks (or tags) spam using
15 | SpamAssassin (L). The proxy is designed
16 | to be transparent to the sending and receiving mail servers and at no point
17 | takes responsibility for the message itself. If a failure occurs within
18 | I (or SpamAssassin) then the mail servers will disconnect and the
19 | sending server is still responsible for retrying the message for as long
20 | as it is configured to do so.
21 |
22 | I uses SpamAssassin to modify (tag) relayed messages based on
23 | their spam score, so all SA settings apply. This is described in the SA
24 | documentation. I will by default only tell SA to tag a
25 | message if it exceeds the spam threshold score, however you can have
26 | it rewrite all messages passing through by adding the --tagall option
27 | (see SA for how non-spam messages are tagged).
28 |
29 | I logs all aspects of its operation to syslog(8), using the
30 | mail syslog facility.
31 |
32 | The latest version can be found at L.
33 |
34 |
35 | =head1 SYNOPSIS
36 |
37 | B I<[ options ]>
38 |
39 | Options:
40 |
41 | --config Load options from file(s).
42 |
43 | --host [:] Hostname/IP and optional port to listen on.
44 | --port Port to listen on (alternate syntax to above).
45 | --socket UNIX socket to listen on.
46 | --socket-perms The octal mode to set on the UNIX socket.
47 | --relayhost [:] Host and optional port to relay mail to.
48 | --relayport Port to relay to (alternate syntax to above).
49 | --relaysocket UNIX socket to relay to.
50 |
51 | --min-servers | -mns The minimum number of servers to keep running.
52 | --min-spare | -mnsp The minimum number of servers to have waiting.
53 | --max-spare | -mxsp The maximum number of servers to have waiting.
54 | --max-servers | -mxs The maximum number of child servers to start.
55 | --maxrequests or -r Maximum requests that each child can process.
56 | --childtimeout Time out children after this many seconds.
57 | --satimeout Time out SpamAssassin after this many seconds.
58 | --child-name-template [s] Template for formatting child process name.
59 |
60 | --pid or -p Store the daemon's process ID in this file.
61 | --user or -u Specifies the user that the daemon runs as.
62 | --group or -g Specifies the group that the daemon runs as.
63 |
64 | --[no]detach Detach from the console daemonize (default).
65 | --[no]setsid Completely detach from stderr with setsid().
66 |
67 | --maxsize n Maximum size of mail to scan (in KB).
68 | --dose (D)ie (o)n (s)pamAssassin (e)rrors.
69 | --tagall Tag all messages with SA headers, not just spam.
70 | --set-envelope-headers Set X-Envelope-From and X-Envelope-To headers.
71 | --set-envelope-from Set X-Envelope-From header only.
72 |
73 | --local-only or -L Turn off all SA network-based tests.
74 | --homedir Use the specified directory as SA home.
75 | --saconfig Use the file for SA "user_prefs" configuration.
76 |
77 | --logfile or -o Destination for logs (syslog|stderr|).
78 | --logsock or -ls Allows specifying the syslog socket type.
79 | --logident or -li Specify syslog identity name.
80 | --logfacility or -lf Specify syslog facility (log name).
81 | --log-rules-hit or -rh Log the names of each matched SA test per mail.
82 | --debug or -d [] Controls extra debug logging.
83 |
84 | --help | -h | -? [txt] Show basic command-line usage.
85 | -hh | -?? [txt] Show short option descriptions (this text).
86 | -hhh | -??? [txt] Show usage summary and full option descriptions.
87 | --man [html|txt] Show full docs a man page or HTML/plain text.
88 | --show defaults| Print default option values or and exit.
89 | --version Print version information and exit.
90 |
91 | Compatibility with previous SpamPD versions:
92 |
93 | --children or -c Same as --max-servers | -mxs (since v2.60).
94 |
95 | Deprecated since SpamAssassin v3:
96 |
97 | --auto-whitelist or -aw Use the SA global auto-whitelist feature.
98 |
99 |
100 | =head1 REQUIRES
101 |
102 | Perl modules:
103 |
104 | =over 5
105 |
106 | =item B
107 |
108 | =item B (>= v0.89, v2.009+ recommended) with B and/or B submodules.
109 |
110 | =item B
111 |
112 | =item B
113 |
114 | =item B (if using TCP/IP sockets)
115 |
116 | =item B (if using UNIX sockets)
117 |
118 | =back
119 |
120 | =head1 OPERATION
121 |
122 | I is meant to operate as an S/LMTP mail proxy which passes
123 | each message through SpamAssassin for analysis. Note that I
124 | does not do anything other than check for spam, so it is not suitable as
125 | an anti-relay system. It is meant to work in conjunction with your
126 | regular mail system. Typically one would pipe any messages they wanted
127 | scanned through I after initial acceptance by your MX host.
128 | This is especially useful for using Postfix's (http://www.postfix.org)
129 | advanced content filtering mechanism, although certainly not limited to
130 | that application.
131 |
132 | Please re-read the second sentence in the above paragraph. You should NOT
133 | enable I to listen on a public interface (IP address) unless you
134 | know exactly what you're doing! It is very easy to set up an open relay this
135 | way.
136 |
137 | Here are some simple examples (square brackets in the "diagrams" indicate
138 | physical machines):
139 |
140 | =over 2
141 |
142 | =item B
143 |
144 | The firewall/gateway MTA would be configured to forward all of its mail
145 | to the port that I listens on, and I would relay its
146 | messages to port 25 of your internal server. I could either
147 | run on its own host (and listen on any port) or it could run on either
148 | mail server (and listen on any port except port 25).
149 |
150 | Internet ->
151 | [ MX gateway (@inter.net.host:25) -> spampd (@localhost:2025) ] ->
152 | [ Internal mail (@private.host.ip:25) ]
153 |
154 | =item B
155 |
156 | Please see the F that came with the Postfix distribution. You
157 | need to have a version of Postfix which supports this (ideally v.2 and up).
158 |
159 | Internet -> [ Postfix (@inter.net.host:25) ->
160 | spampd (@localhost:10025) ->
161 | Postfix (@localhost:10026) ] -> final delivery
162 |
163 | =back
164 |
165 | Note that these examples only show incoming mail delivery. Since it is
166 | often unnecessary to scan mail coming from your network, it may be desirable
167 | to set up a separate outbound route which bypasses I.
168 |
169 | =head2 Scalable Mode
170 |
171 | Since v2.60 I can optionally run in "scalable mode" which dynamically adjusts the number
172 | of child servers which can process requests simultaneously. This is activated automatically if the
173 | C<--min-servers> option is specifically set to be lower than C<--max-servers>.
174 |
175 | Historically I inherited from the module I which only allows for
176 | a static number of child servers to be running at once. This new option essentially allows for inheriting from
177 | I which features dynamic allocation of child servers, with some tunable parameters.
178 | (The reason I wasn't used to begin with is because older versions of it didn't seem to work...
179 | it was an old TODO to try again later.)
180 |
181 | Here is what the I documentation has to say (option names changed to match I):
182 |
183 | I<"This personality binds to one or more ports and then forks C<--min-servers> child process. The server
184 | will make sure that at any given time there are C<--min-spare> servers available to receive a client
185 | request, up to C<--max-servers>. Each of these children will process up to C<--maxrequests> client
186 | connections. This type is good for a heavily hit site, and should scale well for most applications.">
187 |
188 | Some experimentation and tuning will likely be needed to get the best performance vs. efficiency. Keep in mind
189 | that a SIGHUP sent to the parent process will reload configuration files and restart child servers gracefully
190 | (handy for tuning a busy site).
191 |
192 | See the documentation for C<--min-servers>, C<--max-servers>, C<--min-spare>, and C<--max-spare> options,
193 | and also the section about L"Other Net::Server Options"> for tuning parameters and links to further documentation.
194 |
195 |
196 | =head1 INSTALLATION AND CONFIGURATION
197 |
198 | I can be run directly from the command prompt if desired. This is
199 | useful for testing purposes, but for long term use you probably want to put
200 | it somewhere like /usr/bin or /usr/local/bin and execute it at system startup.
201 | For example on Red Hat-style Linux system one can use a script in
202 | /etc/rc.d/init.d to start I (a L