1

I have Postfix/Dovecot/Spamassassin server with following email accoounts:

virtual_mailbox_maps:
info@domain domain/info/
service@domain domain/info/

recipient_bcc_maps
info@domain bcc@domain2
service@domain bcc@domain2

So, I expect to have emails for both info@ and service@ delivered to single mailbox and each email forwarded to external address. And it works, but very often Postifx delivers duplicate emails to BCC defined in recipient_bcc_maps. Email is delivered to local account in single copy.

Here is example of such duplicated delivery from postfix logs:

Aug 12 12:24:18 mail-server postfix/smtpd[29828]: C251A1009B: client=sender.host[IP]
Aug 12 12:24:18 mail-server postfix/cleanup[29834]: C251A1009B: message-id=<ID1>
Aug 12 12:24:18 mail-server postfix/qmgr[29197]: C251A1009B: from=<sender@external.domain>, size=1974, nrcpt=2 (queue active)
Aug 12 12:24:19 mail-server postfix/smtpd[29828]: disconnect from sender.host[IP] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7
Aug 12 12:24:19 mail-server postfix/pickup[29196]: 9859E10173: uid=1004 from=<sender@external.domain>
Aug 12 12:24:19 mail-server postfix/cleanup[29834]: 9859E10173: message-id=<ID1>
Aug 12 12:24:19 mail-server postfix/qmgr[29197]: 9859E10173: from=<sender@external.domain>, size=2390, nrcpt=2 (queue active)
Aug 12 12:24:19 mail-server postfix/pipe[29836]: C251A1009B: to=<service@domain>, relay=spamassassin, delay=0.83, delays=0.12/0.01/0/0.7, dsn=2.0.0, status=sent (delivered via spamassassin service)
Aug 12 12:24:19 mail-server postfix/virtual[29842]: 9859E10173: to=<service@domain>, relay=virtual, delay=0.01, delays=0/0.01/0/0, dsn=2.0.0, status=sent (delivered to maildir)
Aug 12 12:24:20 mail-server postfix/pickup[29196]: 01B7C10174: uid=1004 from=<sender@external.domain>
Aug 12 12:24:20 mail-server postfix/cleanup[29834]: 01B7C10174: message-id=<ID1>
Aug 12 12:24:20 mail-server postfix/pipe[29835]: C251A1009B: to=<bcc@other.external.domain>, relay=spamassassin, delay=1.2, delays=0.12/0/0/1.1, dsn=2.0.0, status=sent (delivered via spamassassin service)
Aug 12 12:24:20 mail-server postfix/qmgr[29197]: C251A1009B: removed
Aug 12 12:24:20 mail-server postfix/qmgr[29197]: 01B7C10174: from=<sender@external.domain>, size=2398, nrcpt=1 (queue active)
Aug 12 12:24:25 mail-server postfix/smtp[29847]: 01B7C10174: to=<bcc@other.external.domain>, relay=bcc.host[IP]:25, delay=5.4, delays=0/0.01/5.1/0.27, dsn=2.0.0, status=sent (250 OK id=1oMRq5-00FIxG-4V)
Aug 12 12:24:25 mail-server postfix/qmgr[29197]: 01B7C10174: removed
Aug 12 12:24:25 mail-server postfix/smtp[29843]: 9859E10173: to=<bcc@other.external.domain>, relay=bcc.host[IP]:25, delay=5.9, delays=0/0.01/5.6/0.29, dsn=2.0.0, status=sent (250 OK id=1oMRq5-00Ax60-6y)
Aug 12 12:24:25 mail-server postfix/qmgr[29197]: 9859E10173: removed

I can not spot a pattern, what is common for those duplicated emails... Any suggestions - what to look for? I don't have much experience with Postifx, maybe I don't see something obvious...

UPDATE

Configuration dump

root@texas:~# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
content_filter = smtp-amavis:[127.0.0.1]:10024
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
mydestination = texas.nettigo.net, localhost, localhost.localdomain, localhost
myhostname = texas.nettigo.net
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_bcc_maps = hash:/etc/postfix/rcpt_bcc
recipient_delimiter = +
relay_domains = $mydestination $secondary_mx_for
relayhost =
secondary_mx_for = nhw.pl
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_proxy_options = speed_adjust
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination check_relay_domains
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
smtpd_sasl_path = private/auth-client
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt
smtpd_tls_key_file = /etc/ssl/private/smtpd.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = /etc/postfix/vhosts
virtual_mailbox_maps = hash:/etc/postfix/vmaps
virtual_minimum_uid = 1000
virtual_uid_maps = static:5000

root@texas:~# postconf -M
smtp       inet  n       -       y       -       -       smtpd -o content_filter=spamassassin
spamassassin unix -      n       n       -       -       pipe user=spamd argv=/usr/bin/spamc -s 640000 -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
submission inet  n       -       y       -       -       smtpd
pickup     unix  n       -       y       60      1       pickup -o content_filter= -o receive_override_options=no_header_body_checks
cleanup    unix  n       -       y       -       0       cleanup
qmgr       unix  n       -       n       300     1       qmgr
tlsmgr     unix  -       -       y       1000?   1       tlsmgr
rewrite    unix  -       -       y       -       -       trivial-rewrite
bounce     unix  -       -       y       -       0       bounce
defer      unix  -       -       y       -       0       bounce
trace      unix  -       -       y       -       0       bounce
verify     unix  -       -       y       -       1       verify
flush      unix  n       -       y       1000?   0       flush
proxymap   unix  -       -       n       -       -       proxymap
proxywrite unix  -       -       n       -       1       proxymap
smtp       unix  -       -       y       -       -       smtp
relay      unix  -       -       y       -       -       smtp
showq      unix  n       -       y       -       -       showq
error      unix  -       -       y       -       -       error
retry      unix  -       -       y       -       -       error
discard    unix  -       -       y       -       -       discard
local      unix  -       n       n       -       -       local
virtual    unix  -       n       n       -       -       virtual
lmtp       unix  -       -       y       -       -       lmtp
anvil      unix  -       -       y       -       1       anvil
scache     unix  -       -       y       -       1       scache
maildrop   unix  -       n       n       -       -       pipe flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp       unix  -       n       n       -       -       pipe flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail     unix  -       n       n       -       -       pipe flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp      unix  -       n       n       -       -       pipe flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n       n       -       2       pipe flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman    unix  -       n       n       -       -       pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user}
smtp-amavis unix -       -       y       -       2       smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes -o max_use=20
127.0.0.1:10025 inet n   -       y       -       -       smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -o smtpd_delay_reject=no -o smtpd_client_restrictions=permit_mynetworks,reject -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o smtpd_data_restrictions=reject_unauth_pipelining -o smtpd_end_of_data_restrictions= -o mynetworks=127.0.0.0/8 -o smtpd_error_sleep_time=0 -o smtpd_soft_error_limit=1001 -o smtpd_hard_error_limit=1000 -o smtpd_client_connection_count_limit=0 -o smtpd_client_connection_rate_limit=0 -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks
Netmaniac
  • 11
  • 2
  • 1
    Please append a postfix configuration as described in the tag wiki page. – Nikita Kipriyanov Aug 12 '22 at 11:30
  • 1
    I have updated post, and attached postconf -m & -M output – Netmaniac Aug 12 '22 at 13:18
  • You will have an easier time diagnosing issues like this if you add `-o syslog_name=example` options to services instantiated multiple times in master.cf - that way your logs will clarify that options are applied first in one service, then in another. – anx Aug 13 '22 at 10:35

1 Answers1

0

It is copied twice because it traverses two smtpd instances both inheriting your global (main.cf) bcc maps configuration, as a consequence of how you integrated spamassassin into your server.

Edit your master.cf and add to the options specified after 127.0.0.1:10025, there already are a few options cleared or disabled for that specific instance.

127.0.0.1:10025 ...
-o ...
-o recipient_bcc_maps=
-o ...

That way you will be disabling the behaviour the second time, while keeping it on on at the receiving side.

anx
  • 8,963
  • 5
  • 24
  • 48
  • see also [Postfix master.cf versus main.cf](https://serverfault.com/questions/462825/postfix-master-cf-versus-main-cf) – anx Aug 13 '22 at 10:31
  • OK, I understand. I have added that option after 127.0.0.1:10025 and as far I understand how Postfix works it should stop duplicate deliveries. Thank You. – Netmaniac Aug 13 '22 at 11:02