1 (edited by oicrambc 2012-08-11 07:13:09)

Topic: No DKIM-Signature

==== Required information ====
- iRedMail version and backend (LDAP/MySQL/PGSQL): 0.7.4
- Linux/BSD distribution name and version: UBUNTU 10.04 Server 64 bits
- Any related log? Log is helpful for troubleshooting.
====

Hello everyone, I'm doing the installation of DKIM to prevent my email being marked as SPAM.

I am able to get a response from the domain, testing the utility of such grants amavis ok, but my emails are accused as without DKIM signature.

See my data:

amavisd-new testkeys

TESTING#1: dkim._domainkey.mydomain.mg.gov.br => pass
dig -t TXT dkim._domainkey.mydomain.mg.gov.br

; <<>> DiG 9.7.0-P1 <<>> -t TXT dkim._domainkey.mydomain.mg.gov.br
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20714
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;dkim._domainkey.mydomain.mg.gov.br. IN TXT

;; ANSWER SECTION:
dkim._domainkey.mydomain.mg.gov.br. 60 IN TXT "v=DKIM1\; p=" "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRM5ob8Awh6aSj7SSc3cXnRvt7" "0Q3xJiKdZ9YFW3DUyE3XnDAYuIWtXk2w9/EjziWf3i1cSKspmFcomIFAhs3lrv/J" "sW4qHC9tl1wVna32WiFCuh5BzO5prAKw4ZyWO+GHU3gZtopH+BbjTFbz1Oto6Lxf" "R2pGIdiI3eOi/z/SwQIDAQAB"

;; AUTHORITY SECTION:
mydomain.mg.gov.br.    17    IN    NS    ns1.mydomain.mg.gov.br.

;; Query time: 22 msec
;; SERVER: 189.113.xx.xx#53(189.113.xx.xx)
;; WHEN: Fri Aug 10 20:02:22 2012
;; MSG SIZE  rcvd: 317

Gmail response:

Delivered-To: email@gmail.com
Received: by 10.223.116.19 with SMTP id k19csp37770faq;
        Fri, 10 Aug 2012 15:51:14 -0700 (PDT)
Received: by 10.236.200.232 with SMTP id z68mr4434805yhn.46.1344639074282;
        Fri, 10 Aug 2012 15:51:14 -0700 (PDT)
Return-Path: <informatica@mydomain.mg.gov.br>
Received: from ns1.mydomain.mg.gov.br (mydomain.mg.gov.br. [189.113.xx.xx])
        by mx.google.com with ESMTP id i18si79053anl.37.2012.08.10.15.51.10;
        Fri, 10 Aug 2012 15:51:10 -0700 (PDT)
Received-SPF: pass (google.com: domain of informatica@mydomain.mg.gov.br designates 189.113.xx.xx as permitted sender) client-ip=189.113.xx.xx;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of informatica@mydomain.mg.gov.br designates 189.113.xx.xx as permitted sender) smtp.mail=informatica@mydomain.mg.gov.br
Received: by ns1.mydomain.mg.gov.br (Postfix, from userid 33)
    id 722F01522DEB; Fri, 10 Aug 2012 19:51:08 -0300 (BRT)
To: Oicrambc <email@gmail.com>
Subject: teste2000
X-PHP-Originating-Script: 0:main.inc
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8;
 format=flowed
Content-Transfer-Encoding: 8bit
Date: Fri, 10 Aug 2012 19:51:08 -0300
From: =?UTF-8?Q?Setor_de_Inform=C3=A1tica?=
 <informatica@mydomain.mg.gov.br>
Message-ID: <2f587affbf9740e0a2b61043fe195311@mydomain.mg.gov.br>
X-Sender: informatica@mydomain.mg.gov.br
User-Agent: Roundcube Webmail/0.7.1

Does anyone see the problem?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: No DKIM-Signature

Did you check mail header of the email you sent out? No DKIM related header?

Please paste whole /etc/amavis/conf.d/50-user here to help troubleshoot. REMOVE SQL/LDAP passwords before posting.

3

Re: No DKIM-Signature

ZhangHuangbin wrote:

Did you check mail header of the email you sent out? No DKIM related header?

Please paste whole /etc/amavis/conf.d/50-user here to help troubleshoot. REMOVE SQL/LDAP passwords before posting.

Wow dude, thanks for the help. Below is my 50-user file:

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
#


#------------ Do not modify anything below this line -------------
#{1}


chomp($mydomain = "mydomain.mg.gov.br");
@local_domains_maps = [".$mydomain", "mydomain.mg.gov.br"];
#@mynetworks = qw( 127.0.0.0/8 [::1] [FE80::]/10 [FEC0::]/10
#                  10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 );

$interface_policy{'10024'} = 'DKIM_ALWAYS';
$policy_bank{'DKIM_ALWAYS'} = { originating => 1, };

# listen on multiple TCP ports. 9998 is used for releasing quarantined mails.
$inet_socket_port = [10024, 9998,];

# Enable virus check.
@bypass_virus_checks_maps = (
   \%bypass_virus_checks,
   \@bypass_virus_checks_acl,
   $bypass_virus_checks_re,
   );

# Enable spam check.
@bypass_spam_checks_maps = (
    \%bypass_spam_checks,
    \@bypass_spam_checks_acl,
    $bypass_spam_checks_re,
    );

$virus_admin = "root\@$mydomain"; # due to D_DISCARD default
$mailfrom_notify_admin = "root\@$mydomain";
$mailfrom_notify_recip = "root\@$mydomain";
$mailfrom_notify_spamadmin = "root\@$mydomain";

# Mail notify.
$mailfrom_notify_admin     = "root\@$mydomain";  # notifications sender
$mailfrom_notify_recip     = "root\@$mydomain";  # notifications sender
$mailfrom_notify_spamadmin = "root\@$mydomain"; # notifications sender
$mailfrom_to_quarantine = ''; # null return path; uses original sender if undef

# Disable defang banned mail.
$defang_banned = 0;  # MIME-wrap passed mail containing banned name

$policy_bank{'MYNETS'} = {   # mail originating from @mynetworks
  originating => 1,  # is true in MYNETS by default, but let's make it explicit
  os_fingerprint_method => undef,  # don't query p0f for internal clients
  allow_disclaimers => 1,  # enables disclaimer insertion if available
};

$policy_bank{'ORIGINATING'} = {  # mail supposedly originating from our users
  originating => 1,  # declare that mail was submitted by our smtp client
  allow_disclaimers => 1,  # enables disclaimer insertion if available
  # notify administrator of locally originating malware
  virus_admin_maps => ["root\@$mydomain"],
  spam_admin_maps  => ["root\@no-ip.org"],
  warnbadhsender   => 0,
  #warnvirussender  => 1,
  #warnspamsender   => 1,
  # forward to a smtpd service providing DKIM signing service
  #forward_method => 'smtp:[127.0.0.1]:10027',
  # force MTA conversion to 7-bit (e.g. before DKIM signing)
  smtpd_discard_ehlo_keywords => ['8BITMIME'],
  bypass_banned_checks_maps => [1],  # allow sending any file names and types
  terminate_dsn_on_notify_success => 0,  # don't remove NOTIFY=SUCCESS option
};

# SpamAssassin debugging. Default if off(0).
# Note: '$log_level' variable above is required for SA debug.
$log_level = 0;              # verbosity 0..5, -d
$sa_debug = 0;

# Set hostname.
$myhostname = "ns1.mydomain.mg.gov.br";

# Set listen IP/PORT.
$notify_method  = 'smtp:[127.0.0.1]:10025';
$forward_method = 'smtp:[127.0.0.1]:10025';

# Set default action.
# Available actions: D_PASS, D_BOUNCE, D_REJECT, D_DISCARD.
$final_virus_destiny      = D_DISCARD;
$final_banned_destiny     = D_PASS;
$final_spam_destiny       = D_BOUNCE;
$final_bad_header_destiny = D_PASS;

@av_scanners = (

    #### http://www.clamav.net/
    ['ClamAV-clamd',
    \&ask_daemon, ["CONTSCAN {}\n", "/tmp/clamd.socket"],
    qr/\bOK$/, qr/\bFOUND$/,
    qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
);

@av_scanners_backup = (

    ### http://www.clamav.net/   - backs up clamd or Mail::ClamAV
    ['ClamAV-clamscan', 'clamscan',
    "--stdout --disable-summary -r --tempdir=$TEMPBASE {}", [0], [1],
    qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
);

# This policy will perform virus checks only.
#$interface_policy{'10026'} = 'VIRUSONLY';
#$policy_bank{'VIRUSONLY'} = { # mail from the pickup daemon
#    bypass_spam_checks_maps   => [1],  # don't spam-check this mail
#    bypass_banned_checks_maps => [1],  # don't banned-check this mail
#    bypass_header_checks_maps => [1],  # don't header-check this mail
#};

# Allow SASL authenticated users to bypass scanning. Typically SASL
# users already submit messages to the submission port (587) or the
# smtps port (465):
#$interface_policy{'10026'} = 'SASLBYPASS';
#$policy_bank{'SASLBYPASS'} = {  # mail from submission and smtps ports
#    bypass_spam_checks_maps   => [1],  # don't spam-check this mail
#    bypass_banned_checks_maps => [1],  # don't banned-check this mail
#    bypass_header_checks_maps => [1],  # don't header-check this mail
#};

# Apply to mails which coming from internal networks or authenticated
# roaming users.
# mail supposedly originating from our users
$policy_bank{'MYUSERS'} = {
    # declare that mail was submitted by our smtp client
    originating => 1,

    # enables disclaimer insertion if available
    allow_disclaimers => 1,

    # notify administrator of locally originating malware
    virus_admin_maps => ["root\@$mydomain"],
    spam_admin_maps  => ["root\@$mydomain"],
    warnbadhsender   => 0,

    # forward to a smtpd service providing DKIM signing service
    forward_method => 'smtp:[127.0.0.1]:10027',

    # force MTA conversion to 7-bit (e.g. before DKIM signing)
    smtpd_discard_ehlo_keywords => ['8BITMIME'],

    # don't remove NOTIFY=SUCCESS option
    terminate_dsn_on_notify_success => 0,

    # don't perform spam/virus/header check.
    #bypass_spam_checks_maps => [1],
    #bypass_virus_checks_maps => [1],
    #bypass_header_checks_maps => [1],

    # allow sending any file names and types
    bypass_banned_checks_maps => [1],
};

# regular incoming mail, originating from anywhere (usually from outside)
#$policy_bank{'EXT'} = {
#  # just use global settings, no special overrides
#};

#
# Port used to release quarantined mails.
#
$interface_policy{'9998'} = 'AM.PDP-INET';
$policy_bank{'AM.PDP-INET'} = {
    protocol => 'AM.PDP',       # select Amavis policy delegation protocol
    inet_acl => [qw( 127.0.0.1 [::1] )],    # restrict access to these IP addresses
    auth_required_release => 1,    # 0 - don't require secret_id for amavisd-release
    #log_level => 4,
    #always_bcc_by_ccat => {CC_CLEAN, 'admin@example.com'},
};

#########################
# Quarantine mails.
#

# Don't quarantine mails with bad header.
$bad_header_quarantine_method = undef;

# Quarantine SPAM.
#$spam_quarantine_to = 'spam-quarantine';

# Quarantine method. How to store mail body.
#   - 'local:spam-%i-%m', store mail on local file system.
#   - 'sql:', store mail body in MySQL. 
#$spam_quarantine_method = 'sql:';

#########################
# Quarantine VIRUS mails.
#
# Quarantine VIRUS into local file system. Default is 'virus-quarantine'.
#$virus_quarantine_to     = 'virus-quarantine';

# Quarantine method. How to store VIRUS mail body. Default is 'local:virus-%m'.
# VIRUS is quarantined into local file system by default.
#$virus_quarantine_method = 'sql:';

# Modify email subject, add '$sa_spam_subject_tag'.
#   0:  disable
#   1:  enable
$sa_spam_modifies_subj = 1;

# remove existing headers
#$remove_existing_x_scanned_headers= 0;
#$remove_existing_spam_headers = 0;

# Leave empty (undef) to add no header.
# Modify /usr/sbin/amavisd or /usr/sbin/amavisd-new file to add customize header in:
#
#   sub add_forwarding_header_edits_per_recip
#
#$X_HEADER_TAG = 'X-Virus-Scanned';
#$X_HEADER_LINE = "by amavisd at $myhostname";

# Notify virus sender?
#$warnvirussender = 0;

# Notify spam sender?
#$warnspamsender = 0;

# Notify sender of banned files?
$warnbannedsender = 0;

# Notify sender of syntactically invalid header containing non-ASCII characters?
$warnbadhsender = 0;

# Notify virus (or banned files) RECIPIENT?
#  (not very useful, but some policies demand it)
$warnvirusrecip = 0;
$warnbannedrecip = 0;

# Notify also non-local virus/banned recipients if $warn*recip is true?
#  (including those not matching local_domains*)
$warn_offsite = 0;

#$notify_sender_templ      = read_text('/var/amavis/notify_sender.txt');
#$notify_virus_sender_templ= read_text('/var/amavis/notify_virus_sender.txt');
#$notify_virus_admin_templ = read_text('/var/amavis/notify_virus_admin.txt');
#$notify_virus_recips_templ= read_text('/var/amavis/notify_virus_recips.txt');
#$notify_spam_sender_templ = read_text('/var/amavis/notify_spam_sender.txt');
#$notify_spam_admin_templ  = read_text('/var/amavis/notify_spam_admin.txt');
# Hope to fix 'nested MAIL command' issue on high load server.
$smtp_connection_cache_enable = 0;

# The default set of header fields to be signed can be controlled
# by setting %signed_header_fields elements to true (to sign) or
# to false (not to sign). Keys must be in lowercase, e.g.:
# 0 -> off
# 1 -> on
$signed_header_fields{'received'} = 0;
$signed_header_fields{'to'} = 1;

# Make sure it sings all inbound mails, avoid error log like this:
# 'dkim: not signing inbound mail'.
$originating = 1;

# Add dkim_key here.
dkim_key("mydomain.mg.gov.br", "dkim", "/var/lib/dkim/mydomain.mg.gov.br.pem");

# Note that signing mail for subdomains with a key of a parent
# domain is treated by recipients as a third-party key, which
# may 'hold less merit' in their eyes. If one has a choice,
# it is better to publish a key for each domain (e.g. host1.a.cn)
# if mail is really coming from it. Sharing a pem file
# for multiple domains may be acceptable, so you don't need
# to generate a different key for each subdomain, but you
# do need to publish it in each subdomain. It is probably
# easier to avoid sending addresses like host1.a.cn and
# always use a parent domain (a.cn) in 'From:', thus
# avoiding the issue altogether.

# Add new dkim_key for other domain.
#dkim_key('Your_New_Domain_Name', 'dkim', 'Your_New_Pem_File');

@dkim_signature_options_bysender_maps = ( {

    # explicit 'd' forces a third-party signature on foreign (hosted) domains
    "mydomain.mg.gov.br"  => { d => "mydomain.mg.gov.br", a => 'rsa-sha256', ttl => 10*24*3600 },
    '.' => { a => 'rsa-sha256', c => 'relaxed/simple', ttl => 30*24*3600 },
} );
$enable_dkim_verification = 1;  # enable DKIM signatures verification
$enable_dkim_signing = 1;    # load DKIM signing code, keys defined by dkim_key
# ------------ Disclaimer Setting ---------------
# Uncomment this line to enable singing disclaimer in outgoing mails.
#$defang_maps_by_ccat{+CC_CATCHALL} = [ 'disclaimer' ];

# Program used to signing disclaimer in outgoing mails.
$altermime = '/usr/bin/altermime';

# Disclaimer in plain text formart.
@altermime_args_disclaimer = qw(--disclaimer=/etc/postfix/disclaimer/_OPTION_.txt --disclaimer-html=/etc/postfix/disclaimer/_OPTION_.txt --force-for-bad-html);

@disclaimer_options_bysender_maps = ({
    # Per-domain disclaimer setting: /etc/postfix/disclaimer/host1.iredmail.org.txt
    #'host1.iredmail.org' => 'host1.iredmail.org',

    # Sub-domain disclaimer setting: /etc/postfix/disclaimer/iredmail.org.txt
    #'.iredmail.org'      => 'iredmail.org',

    # Per-user disclaimer setting: /etc/postfix/disclaimer/boss.iredmail.org.txt
    #'boss@iredmail.org'  => 'boss.iredmail.org',

    # Catch-all disclaimer setting: /etc/postfix/disclaimer/default.txt
    '.' => 'default',
},);
# ------------ End Disclaimer Setting ---------------
$sql_allow_8bit_address = 1;
$timestamp_fmt_mysql = 1;
@storage_sql_dsn = (
    ['DBI:mysql:database=amavisd;host=127.0.0.1;port=3306', 'amavisd', 'XXXXXXXXXXX'],
);
# Uncomment below two lines to lookup virtual mail domains from MySQL database.
#@lookup_sql_dsn =  (
#    ['DBI:mysql:database=vmail;host=127.0.0.1;port=3306', 'vmail', 'XXXXXXXXXXXXXXXXXX'],
#);
# For Amavisd-new-2.7.0 and later versions. Placeholder '%d' is available in Amavisd-2.7.0+.
#$sql_select_policy = "SELECT domain FROM domain WHERE domain='%d'";

# For Amavisd-new-2.6.x.
# WARNING: IN() may cause MySQL lookup performance issue.
#$sql_select_policy = "SELECT domain FROM domain WHERE CONCAT('@', domain) IN (%k)";

1;  # insure a defined return

4

Re: No DKIM-Signature

ZhangHuangbin wrote:

Did you check mail header of the email you sent out? No DKIM related header?

Please paste whole /etc/amavis/conf.d/50-user here to help troubleshoot. REMOVE SQL/LDAP passwords before posting.

Yes I checked, there is no sign of dkim. Tested in several emails and websites. yahoo, gmail and beyond those in Brandon Checketts, appmaildev and some who have even forgotten.

5

Re: No DKIM-Signature

As shown in 50-user, you have DKIM signing and verification enabled:

$enable_dkim_verification = 1;  # enable DKIM signatures verification
$enable_dkim_signing = 1;    # load DKIM signing code, keys defined by dkim_key

Does it work if you remove "mydomain.mg.gov.br" line below? (Of course restarting Amavisd service is required after you comment out the line.)

@dkim_signature_options_bysender_maps = ( {
    # explicit 'd' forces a third-party signature on foreign (hosted) domains
    "mydomain.mg.gov.br"  => { d => "mydomain.mg.gov.br", a => 'rsa-sha256', ttl => 10*24*3600 },
    '.' => { a => 'rsa-sha256', c => 'relaxed/simple', ttl => 30*24*3600 },
} );

6

Re: No DKIM-Signature

ZhangHuangbin wrote:

As shown in 50-user, you have DKIM signing and verification enabled:

$enable_dkim_verification = 1;  # enable DKIM signatures verification
$enable_dkim_signing = 1;    # load DKIM signing code, keys defined by dkim_key

Does it work if you remove "mydomain.mg.gov.br" line below? (Of course restarting Amavisd service is required after you comment out the line.)

@dkim_signature_options_bysender_maps = ( {
    # explicit 'd' forces a third-party signature on foreign (hosted) domains
    "mydomain.mg.gov.br"  => { d => "mydomain.mg.gov.br", a => 'rsa-sha256', ttl => 10*24*3600 },
    '.' => { a => 'rsa-sha256', c => 'relaxed/simple', ttl => 30*24*3600 },
} );

did not work, still unsigned

7

Re: No DKIM-Signature

No idea at all. Please turn on debug mode in Amavisd (in 50-user) to see why it doesn't insert DKIM headers:

$log_level = 5;              # verbosity 0..5, -d

8 (edited by oicrambc 2012-08-17 23:50:41)

Re: No DKIM-Signature

For the record, the solution I found was to install dkim-filter (apt-get install dkim-filter) change your two files /etc/defaut/dkim-filter and /etc/dkim-filter.conf then restart the service