postfix send double mail when mail is forwarded

postfix will forward two mail to user when i configure autoreply, sender_bcc and always_bcc. i have used postfix with dovecot and mysql for virtual user configuration. i dont found where is the problem is.

when i send mail from [email protected] to [email protected] and in main.cf i have always_bcc=pranav@sufalam. following are the log.

May 30 07:25:27 sufalammail postfix/smtpd[7827]: connect from unknown[192.168.0.201]
May 30 07:26:58 sufalammail postfix/smtpd[7827]: 69139222DE: client=unknown[192.168.0.201]
May 30 07:27:13 sufalammail postfix/cleanup[7839]: 69139222DE: message-id=<[email protected]>
May 30 07:27:13 sufalammail postfix/qmgr[7824]: 69139222DE: from=<[email protected]>, size=363, nrcpt=2 (queue active)
May 30 07:27:14 sufalammail postfix/pickup[7823]: 050C4222E0: uid=491 from=<[email protected]>
May 30 07:27:14 sufalammail postfix/cleanup[7839]: 050C4222E0: message-id=<[email protected]>
May 30 07:27:14 sufalammail postfix/qmgr[7824]: 050C4222E0: from=<[email protected]>, size=475, nrcpt=3 (queue active)
May 30 07:27:14 sufalammail postfix/pipe[7842]: 69139222DE: to=<[email protected]>, relay=dfilt, delay=93, delays=92/0.04/0/0.59, dsn=2.0.0, status=sent (delivered via dfilt service)
May 30 07:27:14 sufalammail postfix/pipe[7842]: 69139222DE: to=<[email protected]>, relay=dfilt, delay=93, delays=92/0.04/0/0.59, dsn=2.0.0, status=sent (delivered via dfilt service)
May 30 07:27:14 sufalammail postfix/qmgr[7824]: 69139222DE: removed
May 30 07:27:14 sufalammail postfix/virtual[7852]: 050C4222E0: to=<[email protected]>, relay=virtual, delay=0.16, delays=0.03/0.02/0/0.1, dsn=2.0.0, status=sent (delivered to mailbox)
May 30 07:27:14 sufalammail postfix/virtual[7852]: 050C4222E0: to=<[email protected]>, relay=virtual, delay=0.16, delays=0.03/0.02/0/0.11, dsn=2.0.0, status=sent (delivered to mailbox)
May 30 07:27:14 sufalammail postfix/virtual[7852]: 050C4222E0: to=<[email protected]>, relay=virtual, delay=0.16, delays=0.03/0.02/0/0.11, dsn=2.0.0, status=sent (delivered to mailbox)
May 30 07:27:14 sufalammail postfix/qmgr[7824]: 050C4222E0: removed
May 30 07:27:15 sufalammail postfix/smtpd[7827]: disconnect from unknown[192.168.0.201]

active entry of master.cf is show as below.

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -        -       -       -       smtpd
#        -o content_filter=spamfilter:dummy
         -o content_filter=vacation:dummy
         -o content_filter=dfilt:dummy
#       -o cleanup_service_name= cleanupAF
vacation  unix  -       n        n       -       -       pipe
    flags=Rq user=vacation argv=/var/spool/vacation/vacation3.pl -f ${sender} -- ${recipient}
# flags=Rq user=vacation argv=/usr/bin/perl argv=/var/spool/vacation/vacation.pl -f ${sender} -- ${recipient}
#submission inet n       -       n       -       -       smtpd
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n       -       n       -       -       smtpd
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
relay     unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
#spamassassin unix -      n       n       -       -       pipe
#    flags=Rq user=spamd argv=/usr/bin/spamc -u ${user} -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
#dovecot    unix  -       n       n       -       -       pipe
#       flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -d ${recipient}
#spamfilter unix         -       n       n       -       -       pipe
#   flags=Rq user=spamfilter argv=/usr/local/bin/spamfilter.sh -f ${sender} -- ${recipient}
#spamfilter unix -       n       n       -       -       pipe
#    flags=Rq user=vmail argv=/usr/bin/spamc -u ${user}@${domain} -e /usr/sbin/sendmail.postfix -oi -f ${sender} ${recipient}
dfilt     unix    -       n       n       -       -       pipe
    flags=Rq user=filterAlt argv=/etc/postfix/disclaimer -f ${sender} -- ${recipient}
#vacation  unix  -       n        n       -       -       pipe
#    flags=Rq user=vacation argv=/var/spool/vacation/vacation3.pl -f ${sender} -- ${recipient}
cleanupAF unix n - n - 0 cleanup
#-o [email protected]
#-o recipient_bcc_maps=mysql:/etc/postfix/mysql-virtual_always_bcc.cf

same way if i send mail to autoreply user then also sender get two mail.


Solution 1:

Most likely you have a content filter and the always_bcc is being called both before and after the content filter. Customise the smtpd either before or after the content filter to include

-o receive_override_options=no_address_mappings

(Note that options in master.cf can't contain spaces).