9

I set up a mail server with Dovecot, Postfix and AMaViS on Debian Squeeze following the tutorial on workaround.org (ISPmail tutorial for Debian Squeeze). It uses virtual domains and stores the domains, e-mail addresses and accounts in a MySQL database.

Everything works fine – except I am missing some e-mail headers.

Received headers:

  • X-Quarantine-ID
  • X-Virus-Scanned

(With “real” spam and using the GTUBE via sendmail email@example.com < /usr/share/doc/spamassassin/examples/sample-spam.txt)

Missing headers:

  • X-Spam-Flag
  • X-Spam-Score
  • X-Spam-Level
  • X-Spam-Status

But spam e-mails get their subject changed. So I set up everything correct, didn’t I?

How do I get those missing headers in my mails?


Here my AMaViS configuration file (/etc/amavis/conf.d/50-user)

use strict;

#
# Place your configuration directives here.  They will override those in
# earlier files.
#
# See /usr/share/doc/amavisd-new/ for documentation and examples of
# the directives you can use in this file
#

# see <http://workaround.org/ispmail/squeeze/content-scanning-amavis>

$sa_spam_subject_tag = '*** SPAM *** ';
$final_spam_destiny = D_PASS;

$sa_tag_level_deflt = -9999; # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 6.31; # add 'spam detected' headers at that level


@lookup_sql_dsn = ([
    'DBI:mysql:database=mailserver;host=127.0.0.1;port=3306',
    'mailuser',
    'password'
]);

$sql_select_policy = 'SELECT name FROM virtual_domains WHERE CONCAT("@",name) IN (%k)';

#------------ Do not modify anything below this line -------------
1;  # ensure a defined return

If you need more configuration files, log outputs or anything else, please leave a comment below and I will update my post with the information you need :-)

Jan
  • 266
  • 1
  • 3
  • 6

3 Answers3

19

Have you checked this parameter: @local_domains_acl

It is defined on /etc/amavis/conf.d/05-domain_id. According to the Amavisd-new documentation on http://www.ijs.si/software/amavisd/ :

No spam-related headers inserted? Here are some reasons:

  • @local_domains_acl is not correctly set. These headers are only inserted for recipients matching @local_domains_acl lookup (or %local_domains or $local_domains_re or field 'local' in SQL lookups);
  • (...)

Check the output of this command: head -n 1 /etc/mailname

If you will not get exactly your domain name than Amavisd will not apply any change to the headers of your emails. If you want to force the adding of the X-Spam-* headers than you can add something like this @local_domains_acl = ( "." ); on /etc/amavis/conf.d/50-user

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
user172132
  • 191
  • 2
5

(This is really a comment to the previous answer, but the reputation system won't let me)

Setting @local_domains_acl = ( "." ) worked for me, but it seemed like a rather blunt instrument (i.e., spam processing all messages, in or out). Trying a number of alternatives, I eventually found that including localhost would also help (I'm testing with a delivery service on the same box). Thus, in /etc/amavis/conf.d/50-user I have something like:

@local_domains_acl = ( ".mydomain.example.org", "localhost" );

and I'm seeing messages delivered with spam headers added.

(My test setup here is Ubuntu 14.04 server, postfix, amaviz, spamassassin, all installed from standard Ubuntu repositories.)

Graham Klyne
  • 169
  • 1
  • 4
3

The output of command head -n 1 /etc/mailname must be your domain, like example.com.

If the output is something like mail.example.com, that's the bug.

So, you can fix this by changing the file /etc/amavis/conf.d/05-domain_id

Solution #1

Inside /etc/amavis/conf.d/05-domain_id:

Change:

    chomp($mydomain = `head -n 1 /etc/mailname`);

To:

    chomp($mydomain = `hostname -d`);

PS: The output of hostname -d must be your domain, like example.com.

Solution #2

Inside /etc/amavis/conf.d/05-domain_id:

Change:

    chomp($mydomain = `head -n 1 /etc/mailname`);

To:

    $mydomain = "example.com";