1

Topic: Trying to "monitor incoming or outgoing mails with BCC "

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.1
- Deployed with iRedMail Easy or the downloadable installer? downloadable
- Linux/BSD distribution name and version: Ubuntu 18.04lts
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): mysql
- Web server (Apache or Nginx):nginx
- Manage mail accounts with iRedAdmin-Pro? no
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hello everybody,

I am testing iredmail and trying to setup the Monitor incoming and outgoing mail with bcc option.
My problem is that i could not make the incoming option to work.
First, the outgoing part is working fine. I tried these two alternatives for sender_bcc_user tables with success:

THIS WORKS. When test@kakata.com send an email the destination receive it and bcc_address in the table receive its copy. Excellent.
Option 1.
MariaDB [vmail]> select * from sender_bcc_user;
+-----------------+-------------------+------------+---------------------+---------------------+---------------------+--------+
| username        | bcc_address       | domain     | created             | modified            | expired             | active |
+-----------------+-------------------+------------+---------------------+---------------------+---------------------+--------+
| test@kakata.com | testxx@kakata.com | kakata.com | 2020-03-11 19:42:40 | 1970-01-01 01:01:01 | 9999-12-31 00:00:00 |      1 |
+-----------------+-------------------+------------+---------------------+---------------------+---------------------+--------+
Option 2.
MariaDB [vmail]> select * from sender_bcc_user;
+-----------------+------------------+------------+---------------------+---------------------+---------------------+--------+
| username        | bcc_address      | domain     | created             | modified            | expired             | active |
+-----------------+------------------+------------+---------------------+---------------------+---------------------+--------+
| test@kakata.com | testxx@gmail.com | kakata.com | 2020-03-11 19:42:40 | 1970-01-01 01:01:01 | 9999-12-31 00:00:00 |      1 |
+-----------------+------------------+------------+---------------------+---------------------+---------------------+--------+

But for recipient_bcc_user table, nothing seems to work. I tried these two options for recipient_bcc_user table:
When some email is sent to text@kakata.com, testxx does not receive a copy of the email.
Option 1.
MariaDB [vmail]> select * from recipient_bcc_user;
+------------------+------------------+------------+---------------------+---------------------+---------------------+--------+
| username         | bcc_address      | domain     | created             | modified            | expired             | active |
+------------------+------------------+------------+---------------------+---------------------+---------------------+--------+
| test@kakata.com  | testxx@gmail.com | gmail.com  | 2020-03-11 19:44:53 | 1970-01-01 01:01:01 | 9999-12-31 00:00:00 |      1 |
+------------------+------------------+------------+---------------------+---------------------+---------------------+--------+
Option 2. (doesn't work neither)
MariaDB [vmail]> select * from recipient_bcc_user;
+-----------------+-------------------+------------+---------------------+---------------------+---------------------+--------+
| username        | bcc_address       | domain     | created             | modified            | expired             | active |
+-----------------+-------------------+------------+---------------------+---------------------+---------------------+--------+
| test@kakata.com | testxx@kakata.com | kakata.com | 2020-03-11 19:44:53 | 1970-01-01 01:01:01 | 9999-12-31 00:00:00 |      1 |
+-----------------+-------------------+------------+---------------------+---------------------+---------------------+--------+

What i'm doing wrong? Any ideas?

Regards,

Carlos

----

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

2

Re: Trying to "monitor incoming or outgoing mails with BCC "

Please show us related Postfix log while you sending email to trigger the recipient bcc.

3

Re: Trying to "monitor incoming or outgoing mails with BCC "

Hello ZhangHuangbin,

Thank you for your support.

This is the /var/log/mail.log

Mar 16 11:10:05 mx amavis[1139]: starting. /usr/sbin/amavisd-new at mx.kakata.com amavisd-new-2.11.0 (20160426), Unicode aware, LC_ALL="C", LANG="en_US.UTF-8"
Mar 16 11:10:08 mx amavis[1954]: Net::Server: Group Not Defined.  Defaulting to EGID '121 121'
Mar 16 11:10:08 mx amavis[1954]: Net::Server: User Not Defined.  Defaulting to EUID '117'
Mar 16 11:10:09 mx amavis[1954]: No ext program for   .F, tried: unfreeze, freeze -d, melt, fcat
Mar 16 11:10:09 mx amavis[1954]: No ext program for   .zoo, tried: zoo, unzoo
Mar 16 11:10:09 mx amavis[1954]: No decoder for       .F
Mar 16 11:10:09 mx amavis[1954]: No decoder for       .zoo
Mar 16 11:10:09 mx amavis[1954]: Using primary internal av scanner code for clamav-socket
Mar 16 11:10:09 mx amavis[1954]: Found secondary av scanner clamav-clamscan at /usr/bin/clamscan
Mar 16 11:10:14 mx postfix/postfix-script[2381]: starting the Postfix mail system
Mar 16 11:10:15 mx postfix/master[2390]: daemon started -- version 3.3.0, configuration /etc/postfix
Mar 16 11:10:15 mx fetchmail[2481]: starting fetchmail 6.3.26 daemon
Mar 16 11:12:31 mx fetchmail[2481]: 1 message for dummy@kakata.com at pop.readyhosting.com (3685 octets).
Mar 16 11:12:34 mx fetchmail[2481]: reading message dummy@kakata.com@pop.readyhosting.com:1 of 1 (3685 octets) flushed

My /etc/fetchmailrc is:
set postmaster "postmaster@kakata.com"
set no bouncemail
set showdots
set properties ""
set daemon 60

poll "pop.readyhosting.com" with protocol pop3
user "dummy@kakata.com" pass "DUMMYpass123" is "dummy@kakata.com" smtphost "/var/run/dovecot/lmtp"

Current recipients_bcc_user table:
MariaDB [vmail]> select * from recipient_bcc_user;
+------------------+------------------+------------+---------------------+---------------------+---------------------+--------+
| username         | bcc_address      | domain     | created             | modified            | expired             | active |
+------------------+------------------+------------+---------------------+---------------------+---------------------+--------+
| dummy@kakata.com | crpe00@gmail.com | kakata.com | 2020-03-11 19:44:53 | 1970-01-01 01:01:01 | 9999-12-31 00:00:00 |      1 |
+------------------+------------------+------------+---------------------+---------------------+---------------------+--------+
1 row in set (0.00 sec)

Regards,
Carlos

4

Re: Trying to "monitor incoming or outgoing mails with BCC "

Please try to send an email to dummy@kakata.com and show us related Postfix log for troubleshooting.

5

Re: Trying to "monitor incoming or outgoing mails with BCC "

ZhangHuangbin wrote:

Please try to send an email to dummy@kakata.com and show us related Postfix log for troubleshooting.

Hello ZhangHuangbin,

I sent a test mail twice from a gmail account(NormalSender at gmail) to my iredmail server account (dummy at kakata.com) (from 11:11:00 to 11:50:00)

The incoming bcc email address is set as bcc_recipient at gmail in the vmail table.

The email is received Ok from NormalSender gmail but the bcc is not received by the bcc_recipient at gmail account


MariaDB [vmail]> select * from recipient_bcc_user;
+------------------+------------------+------------+---------------------+---------------------+---------------------                                                                                              +--------+
| username         | bcc_address      | domain     | created             | modified            | expired                                                                                                           | active |
+------------------+------------------+------------+---------------------+---------------------+---------------------                                                                                              +--------+
| dummy@kakata.com | bcc_recipient@gmail.com | kakata.com | 2020-03-11 19:44:53 | 1970-01-01 01:01:01 | 9999-12-31 00:00:00                                                                                               |      1 |
+------------------+------------------+------------+---------------------+---------------------+---------------------   


MAIL.LOG
Apr  7 11:11:55 mx fetchmail[2660]: 1 message for dummy@kakata.com at pop.readyhosting.com (3393 octets).
Apr  7 11:11:57 mx fetchmail[2660]: reading message dummy@kakata.com@pop.readyhosting.com:1 of 1 (3393 octets) flushed
Apr  7 11:47:24 mx fetchmail[2660]: 1 message for dummy@kakata.com at pop.readyhosting.com (3392 octets).
Apr  7 11:47:24 mx fetchmail[2660]: reading message dummy@kakata.com@pop.readyhosting.com:1 of 1 (3392 octets) flushed



SYSLOG
Apr  7 11:11:46 mx systemd[1]: Started Session 4 of user administrator.
Apr  7 11:11:55 mx fetchmail[2660]: 1 message for dummy@kakata.com at pop.readyhosting.com (3393 octets).
Apr  7 11:11:57 mx fetchmail[2660]: reading message dummy@kakata.com@pop.readyhosting.com:1 of 1 (3393 octets) flushed
Apr  7 11:17:01 mx CRON[3444]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Apr  7 11:20:56 mx fail2ban.actions        [1478]: NOTICE  [sshd] Unban 62.171.172.225
Apr  7 11:21:22 mx systemd-resolved[820]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr  7 11:21:22 mx systemd-resolved[820]: message repeated 2 times: [ Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.]
Apr  7 11:21:22 mx fail2ban.filter         [1478]: INFO    [sshd] Found 62.171.172.225 - 2020-04-07 11:21:21
Apr  7 11:21:24 mx fail2ban.filter         [1478]: INFO    [sshd] Found 62.171.172.225 - 2020-04-07 11:21:24
Apr  7 11:22:12 mx fail2ban.filter         [1478]: INFO    [sshd] Found 62.171.172.225 - 2020-04-07 11:22:12
Apr  7 11:22:12 mx fail2ban.actions        [1478]: NOTICE  [sshd] Ban 62.171.172.225
Apr  7 11:22:14 mx fail2ban.filter         [1478]: INFO    [sshd] Found 62.171.172.225 - 2020-04-07 11:22:14
Apr  7 11:22:17 mx systemd[1]: Starting Cleanup of Temporary Directories...
Apr  7 11:22:18 mx systemd[1]: Started Cleanup of Temporary Directories.
Apr  7 11:39:01 mx CRON[3822]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
Apr  7 11:39:07 mx systemd[1]: Starting Clean php session files...
Apr  7 11:39:07 mx systemd[1]: Started Clean php session files.
Apr  7 11:47:24 mx fetchmail[2660]: 1 message for dummy@kakata.com at pop.readyhosting.com (3392 octets).
Apr  7 11:47:24 mx fetchmail[2660]: reading message dummy@kakata.com@pop.readyhosting.com:1 of 1 (3392 octets) flushed


SYSLOG (cat/var/log | grep "postfix")
Apr  7 09:59:41 mx postfix/qmgr[2628]: 48xTX96Dn8zbbh7: removed
Apr  7 09:59:41 mx postfix/smtp[31840]: 48xTYQ6DDwzbbnd: to=<bcc_recipient@gmail.com>, relay=smtp.readyhosting.com[65.254.231.80]:587, delay=2.9, delays=0.49/0.47/0.77/1.1, dsn=2.0.0, status=sent (250 OK id=1jLolR-0006uV-H3)
Apr  7 09:59:41 mx postfix/qmgr[2628]: 48xTYQ6DDwzbbnd: removed
Apr  7 09:59:41 mx postfix/smtp[31842]: 48xTYQ6KlKzbbt0: to=<NormalSender@gmail.com>, relay=smtp.readyhosting.com[65.254.231.80]:587, delay=2.9, delays=0.52/0.46/0.75/1.1, dsn=2.0.0, status=sent (250 OK id=1jLolR-0006uU-HG)
Apr  7 09:59:41 mx postfix/qmgr[2628]: 48xTYQ6KlKzbbt0: removed
Apr  7 10:42:16 mx postfix/submission/smtpd[375]: connect from mx.kakata.com[127.0.0.1]
Apr  7 10:42:16 mx postfix/submission/smtpd[375]: Anonymous TLS connection established from mx.kakata.com[127.0.0.1]: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
Apr  7 10:42:17 mx postfix/submission/smtpd[375]: 48xVVd21bfzbbh7: client=mx.kakata.com[127.0.0.1], sasl_method=LOGIN, sasl_username=dummy@kakata.com
Apr  7 10:42:17 mx postfix/cleanup[384]: 48xVVd21bfzbbh7: message-id=<d81168a65943ffe3693b70965f2dbf8c@kakata.com>
Apr  7 10:42:17 mx postfix/qmgr[2628]: 48xVVd21bfzbbh7: from=<dummy@kakata.com>, size=1173, nrcpt=2 (queue active)
Apr  7 10:42:17 mx postfix/submission/smtpd[375]: disconnect from mx.kakata.com[127.0.0.1] ehlo=2 starttls=1 auth=1 mail=1 rcpt=1 data=1 quit=1 commands=8
Apr  7 10:43:18 mx postfix/10025/smtpd[443]: connect from mx.kakata.com[127.0.0.1]
Apr  7 10:43:18 mx postfix/10025/smtpd[444]: connect from mx.kakata.com[127.0.0.1]
Apr  7 10:43:18 mx postfix/10025/smtpd[443]: 48xVWp40Crzbbnd: client=mx.kakata.com[127.0.0.1]
Apr  7 10:43:18 mx postfix/cleanup[384]: 48xVWp40Crzbbnd: message-id=<d81168a65943ffe3693b70965f2dbf8c@kakata.com>
Apr  7 10:43:18 mx postfix/10025/smtpd[444]: 48xVWp4ZF1zbbt0: client=mx.kakata.com[127.0.0.1]
Apr  7 10:43:18 mx postfix/cleanup[447]: 48xVWp4ZF1zbbt0: message-id=<d81168a65943ffe3693b70965f2dbf8c@kakata.com>
Apr  7 10:43:18 mx postfix/10025/smtpd[443]: disconnect from mx.kakata.com[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Apr  7 10:43:18 mx postfix/10025/smtpd[444]: disconnect from mx.kakata.com[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Apr  7 10:43:19 mx postfix/qmgr[2628]: 48xVWp4ZF1zbbt0: from=<dummy@kakata.com>, size=2213, nrcpt=1 (queue active)
Apr  7 10:43:19 mx postfix/qmgr[2628]: 48xVWp40Crzbbnd: from=<dummy@kakata.com>, size=2195, nrcpt=1 (queue active)
Apr  7 10:43:19 mx postfix/amavis/smtp[391]: 48xVVd21bfzbbh7: to=<bcc_recipient@gmail.com>, relay=127.0.0.1[127.0.0.1]:10026, delay=63, delays=0.49/0.12/0.57/62, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 48xVWp40Crzbbnd)
Apr  7 10:43:20 mx postfix/amavis/smtp[388]: 48xVVd21bfzbbh7: to=<NormalSender@gmail.com>, relay=127.0.0.1[127.0.0.1]:10026, delay=63, delays=0.49/0.09/0.59/62, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 48xVWp4ZF1zbbt0)
Apr  7 10:43:20 mx postfix/qmgr[2628]: 48xVVd21bfzbbh7: removed
Apr  7 10:43:21 mx postfix/smtp[448]: Anonymous TLS connection established to smtp.readyhosting.com[65.254.231.80]:587: TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)
Apr  7 10:43:21 mx postfix/smtp[452]: Anonymous TLS connection established to smtp.readyhosting.com[65.254.231.80]:587: TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)
Apr  7 10:43:22 mx postfix/smtp[452]: 48xVWp40Crzbbnd: to=<bcc_recipient@gmail.com>, relay=smtp.readyhosting.com[65.254.231.80]:587, delay=3.9, delays=0.77/1.2/0.75/1.2, dsn=2.0.0, status=sent (250 OK id=1jLpRi-0007Jb-8R)
Apr  7 10:43:22 mx postfix/qmgr[2628]: 48xVWp40Crzbbnd: removed
Apr  7 10:43:22 mx postfix/smtp[448]: 48xVWp4ZF1zbbt0: to=<NormalSender@gmail.com>, relay=smtp.readyhosting.com[65.254.231.80]:587, delay=4, delays=0.73/1.3/0.77/1.2, dsn=2.0.0, status=sent (250 OK id=1jLpRi-0007Ja-8J)
Apr  7 10:43:22 mx postfix/qmgr[2628]: 48xVWp4ZF1zbbt0: removed
Apr  7 11:08:34 mx fail2ban.jail           [1478]: INFO    Creating new jail 'postfix-pregreet-iredmail'
Apr  7 11:08:34 mx fail2ban.jail           [1478]: INFO    Jail 'postfix-pregreet-iredmail' uses pyinotify {}
Apr  7 11:08:34 mx fail2ban.jail           [1478]: INFO    Creating new jail 'postfix-iredmail'
Apr  7 11:08:34 mx fail2ban.jail           [1478]: INFO    Jail 'postfix-iredmail' uses pyinotify {}
Apr  7 11:08:35 mx fail2ban.jail           [1478]: INFO    Jail 'postfix-pregreet-iredmail' started
Apr  7 11:08:35 mx fail2ban.jail           [1478]: INFO    Jail 'postfix-iredmail' started
Apr  7 11:08:44 mx postfix/postfix-script[2614]: starting the Postfix mail system
Apr  7 11:08:44 mx postfix/master[2617]: daemon started -- version 3.3.0, configuration /etc/postfix

6

Re: Trying to "monitor incoming or outgoing mails with BCC "

I can not reproduce this issue. both incoming and outgoing bcc work fine for me.
Please show me output of commands below:

cd /etc/postfix/mysql/
for i in $(ls *cf); do echo $i; postmap -q 'dummy@domain.com' mysql:./$i; done

Replace dummy@domain.com by your real user email address.

7

Re: Trying to "monitor incoming or outgoing mails with BCC "

ZhangHuangbin wrote:

I can not reproduce this issue. both incoming and outgoing bcc work fine for me.
Please show me output of commands below:

cd /etc/postfix/mysql/
for i in $(ls *cf); do echo $i; postmap -q 'dummy@domain.com' mysql:./$i; done

Replace dummy@domain.com by your real user email address.


Hello ZhangHuangbin,

Thank you for your help. This is the output for the commands:

catchall_maps.cf
domain_alias_catchall_maps.cf
domain_alias_maps.cf
recipient_bcc_maps_domain.cf
recipient_bcc_maps_user.cf
bcc_recipient@gmail.com
relay_domains.cf
sender_bcc_maps_domain.cf
sender_bcc_maps_user.cf
bcc_recipient@gmail.com
sender_dependent_relayhost_maps.cf
sender_login_maps.cf
dummy@kakata.com
transport_maps_domain.cf
transport_maps_maillist.cf
transport_maps_user.cf
virtual_alias_maps.cf
dummy@kakata.com
virtual_mailbox_domains.cf
virtual_mailbox_maps.cf
vmail1/kakata.com/d/u/m/dummy-2020.03.03.16.04.48//Maildir/

8

Re: Trying to "monitor incoming or outgoing mails with BCC "

carlosrpevertsz wrote:

recipient_bcc_maps_user.cf
bcc_recipient@gmail.com
...
sender_bcc_maps_user.cf
bcc_recipient@gmail.com

As you can see in the output, both per-user bcc lookup files return correct destination addresses. so Postfix part should be fine. You have to check Postfix log file carefully, or even turn on debug mode in Postfix to figure it out:
https://docs.iredmail.org/debug.postfix.html

Read Postfix log line by line, make sure BCC lookup is triggered by Postfix, then figure out the destination.