Differences between revisions 11 and 12
Revision 11 as of 2014-04-26 08:38:37
Size: 4742
Editor: ?ThomasJackowski
Comment: Fixed version number
Revision 12 as of 2014-04-26 09:10:27
Size: 6287
Editor: ?ThomasJackowski
Comment: Added postfix/SA configuration
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
== Setting up Exim 4 and SA 2.64 to reject spam at SMTP time == = Setup Postfix with SA 3.3.2 (Wheezy) =
This tutorial will show you how to integrate SA into postfix to scan your emails for spam. It is assumed that postfix is installed and configured properly. You will need those packages (and resulting dependencies):
 * postfix
 * spamassassin
 * spamc

== Postfix ==
SA will be used as a content filter for the postfix 'smtp' (and submission) binary. The '''spamc''' binary passes the email to '''spamd''' (daemonized SA) and then back to the mail queue.

=== master.cf ===
Add to your smtp and submission service
{{{
-o content_filter=spamassassin
}}}

which will result at least in

{{{
smtp inet n - - - - smtpd
   -o content_filter=spamassassin
submission inet n - - - - smtpd
   -o content_filter=spamassassin
}}}

or similiar.

We have to add the spamassassin service by adding
{{{
spamassassin unix - n n - - pipe
  user=debian-spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
}}}
at the end of the configuration file.

=== main.cf ===
No changes necessary.

=== Final steps ===
Reload postfix configuration by
{{{
postfix reload
}}}
or
{{{
service postfix reload
}}}

== Spamassassin ==
In the SA config files you can make changes according to your flavor. E.g. in
{{{
/etc/spamassassin/local.cf
}}}
you can uncomment the line
{{{
rewrite_header Subject *****SPAM*****
}}}
to mark spam in your MUA in the message header.

= Setting up Exim 4 and SA 2.64 to reject spam at SMTP time =
Line 26: Line 83:
=== Details === == Details ==
Line 66: Line 123:
=== Important Notes === == Important Notes ==
Line 77: Line 134:
== External Links == = External Links =

Translation(s): English - Italiano


SpamAssassin

SpamAssassin is an extensible email filter which is used to identify spam. It has a wide range of features, uses DNSBL tests, heuristics, bayesian classification and other concepts to tell your spam from ham.

The official SpamAssassin homepage is at http://spamassassin.apache.org/

Versions of Debian Packages

As SpamAssassin is a targetting a moving target, it is wise to keep it quite up-to-date, as spammers adapt to the filters to get their spew through.

Setup Postfix with SA 3.3.2 (Wheezy)

This tutorial will show you how to integrate SA into postfix to scan your emails for spam. It is assumed that postfix is installed and configured properly. You will need those packages (and resulting dependencies):

  • postfix
  • spamassassin
  • spamc

Postfix

SA will be used as a content filter for the postfix 'smtp' (and submission) binary. The spamc binary passes the email to spamd (daemonized SA) and then back to the mail queue.

master.cf

Add to your smtp and submission service

-o content_filter=spamassassin

which will result at least in

smtp      inet  n       -       -       -       -       smtpd
   -o content_filter=spamassassin
submission inet n       -       -       -       -       smtpd
   -o content_filter=spamassassin

or similiar.

We have to add the spamassassin service by adding

spamassassin unix -     n       n       -       -       pipe
  user=debian-spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

at the end of the configuration file.

main.cf

No changes necessary.

Final steps

Reload postfix configuration by

postfix reload

or

service postfix reload

Spamassassin

In the SA config files you can make changes according to your flavor. E.g. in

/etc/spamassassin/local.cf

you can uncomment the line

rewrite_header Subject *****SPAM*****

to mark spam in your MUA in the message header.

Setting up Exim 4 and SA 2.64 to reject spam at SMTP time

<!> This section contains outdated information.

It is fairly easy to set up Exim4 and SA to reject spam in the SMTP dialogue, that is, while the spam is still in transmission and your system is still talking to the spammer.

First of all, you need the exim4-daemon-heavy which has exiscan-acl. The latter allows scanning messages. Then, you need SA installed, and just follow the documentation exiscan-acl-docs.

Details

In the file /etc/exim4/conf.d/main/15_spamassassin-config I have simply the following:

  spamd_address = 127.0.0.1 783

To avoid scanning messages that are destined to postmaster or abuse (and is their damned duty to read) modify the entry in /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt to read:

  accept local_parts = postmaster:abuse
         domains = +local_domains
         set acl_m0 = rfcnames

Then, the rest goes in /etc/exim4/conf.d/acl/40_exim4-config_check_data

Pretty high up, you need:

  accept condition = ${if eq{$acl_m0}{rfcnames} {1}{0}}

And then somewhere far down there:

  warn  message = X-Spam-Score: $spam_score ($spam_bar)
        spam = nobody:true

  warn  message = X-Spam-Flag: YES
        spam = nobody
  warn  message = X-Spam-Report: $spam_report
        spam = nobody
  •   # reject spam at high scores (> 12)
      deny   message = This message scored $spam_score spam points.
             spam = nobody:true
             condition = ${if >{$spam_score_int}{120}{1}{0}}

However, note that any errors can result in loss of valid e-mail, so make sure you have read and understand the official documentation before you use it. This is meant to give a taste of what is involved in getting it working.

Important Notes

It is controversial whether rejecting at SMTP time is such a good idea. The problem is, spammers (and viruses) routinely forge the from address on the envelope. This means that if there is a bounce generated, it will go to this address, which can be randomly generated, or worse, an innocent third party.

Therefore, it is very important that your system doesn't generate a bounce. That's your responsibility. For one thing, you can't accept a message and then bounce it, that would be wrong. You can't, for example, have your secondary MX accept a message and then have your primary reject it. If you are to use this, your primary and secondary MX should have identical configurations with respect to rejecting spam.

The other thing are relays. Spammers often take over relays to obscure the true source of the spams. If a relay under a spammer's control generate a bounce message based on your rejection, that bounce may go to an innocent thrid-party, which would be bad. That's the main reason why some consider this approach harmful.

The advocates of this approach points out that spammers have no interest in generating bounces, as that would only cut into their own spamming bandwidth and make them less efficient. Therefore, one rarely sees a raped relay, or a spammer himself, generate a bounce, which solves the problem.

Other advocates hold the position that "my system, my responsibility, your system, your responsiblity", implying that an administrator would need a heads-up he would get from letting his relay pass on spam.

External Links


FixMe: This page needs to be brought up to date.