1 (edited by rocwhite 2018-04-30 07:17:42)

Topic: Problems with auto BCC for a relayed sender address

======== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.7
- Linux/BSD distribution name and version: Ubuntu 16.04
- 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.
====

I set up a relayed address that uses an external SMTP server as follows.

INSERT INTO sender_relayhost (account, relayhost) VALUES ('@host1.tld1', '[smtp.host1.tld1]:587');

With this I can use "'user1@host1.tld1" as FROM address from both RoundCube and Thunderbird. I then followed the instructions to set up auto BCC rules:

INSERT INTO sender_bcc_user (username, bcc_address, domain, active, created)
       VALUES ('user1@host1.tld1', 'myuser+Sent@mydomain', 'host1.tld1', 1, NOW());
INSERT INTO sender_bcc_user (username, bcc_address, domain, active, created)
       VALUES ('myuser@mydomain.mytld', 'myuser+Sent@mydomain.mytld', 'mydomain.mytld', 1, NOW());

However, only the second row triggers BCC for the hosted address "myuser@mydomain.mytld". The first row does nothing.

Following is something I tried while debugging the issue:

I added "host1.tld1" to the "domain" table, so that "user1@host1.tld1" can be found while looking up sender_bcc_maps:

INSERT INTO domain (domain, transport, active, created) VALUES ('host1.tld1', 'relay:[smtp.host1.tld1]:587', 1, NOW());

However, now when I tested from Thunderbird, I got an SMTP error: postfix/submission/smtpd[644]: NOQUEUE: reject: RCPT from unknown[123.45.67.89]: 550 5.1.0 <user1@host1.tld1>: Sender address rejected: User unknown in virtual mailbox table; from=<user1@host1.tld1> to=<userX@hostX.tldX> proto=ESMTP helo=<[192.168.1.100]>.

What's the correct way to set up auto BCC for a relayed address?

----

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

2

Re: Problems with auto BCC for a relayed sender address

Postfix uses the SMTP AUTH username as the bcc user.

3

Re: Problems with auto BCC for a relayed sender address

ZhangHuangbin wrote:

Postfix uses the SMTP AUTH username as the bcc user.

I logged in to the SMTP server as "myuser@mydomain.mytld" and sent FROM "user1@host1.tld1". If the AUTH username is used as the BCC user, wouldn't the second rule still trigger BCC?

4

Re: Problems with auto BCC for a relayed sender address

rocwhite wrote:

However, now when I tested from Thunderbird, I got an SMTP error: postfix/submission/smtpd[644]: NOQUEUE: reject: RCPT from unknown[123.45.67.89]: 550 5.1.0 <user1@host1.tld1>: Sender address rejected: User unknown in virtual mailbox table; from=<user1@host1.tld1> to=<userX@hostX.tldX> proto=ESMTP helo=<[192.168.1.100]>.

If you add domain "host1.tld1" locally, then all "<user>@host1.tld1" must exist locally.

I'm now confused what the error is.

5 (edited by rocwhite 2018-04-30 07:16:47)

Re: Problems with auto BCC for a relayed sender address

ZhangHuangbin wrote:
rocwhite wrote:

However, now when I tested from Thunderbird, I got an SMTP error: postfix/submission/smtpd[644]: NOQUEUE: reject: RCPT from unknown[123.45.67.89]: 550 5.1.0 <user1@host1.tld1>: Sender address rejected: User unknown in virtual mailbox table; from=<user1@host1.tld1> to=<userX@hostX.tldX> proto=ESMTP helo=<[192.168.1.100]>.

If you add domain "host1.tld1" locally, then all "<user>@host1.tld1" must exist locally.

I'm now confused what the error is.

You can ignore the last part as indicated in my edited question. According to your previous reply:

INSERT INTO sender_bcc_user (username, bcc_address, domain, active, created)
       VALUES ('myuser@mydomain.mytld', 'myuser+Sent@mydomain.mytld', 'mydomain.mytld', 1, NOW());

would be sufficient to bcc all emails sent via SMTP when user is authenticated as 'myuser@mydomain.tld', but it's not working for me.

6

Re: Problems with auto BCC for a relayed sender address

Please show us output of command below:

cd /etc/postfix/mysql/
for cf in $(ls *cf); do echo $cf; postmap -q myuser@mydomain.tld mysql:./$cf; done

7

Re: Problems with auto BCC for a relayed sender address

ZhangHuangbin wrote:

Please show us output of command below:

cd /etc/postfix/mysql/
for cf in $(ls *cf); do echo $cf; postmap -q myuser@mydomain.tld mysql:./$cf; done

Thanks Huangbin. Here is the output:

------
catchall_maps.cf
------
------
domain_alias_catchall_maps.cf
------
------
domain_alias_maps.cf
------
------
recipient_bcc_maps_domain.cf
------
------
recipient_bcc_maps_user.cf
------
------
relay_domains.cf
------
------
sender_bcc_maps_domain.cf
------
------
sender_bcc_maps_user.cf
myuser+Sent@mydomain.tld
------
------
sender_dependent_relayhost_maps.cf
------
------
sender_login_maps.cf
myuser@mydomain.tld
------
------
transport_maps_domain.cf
------
------
transport_maps_user.cf
------
------
virtual_alias_maps.cf
myuser@mydomain.tld
------
------
virtual_mailbox_domains.cf
------
------
virtual_mailbox_maps.cf
vmail1/mydomain.tld/path/to/myuser-2018.04.24.05.06.01//Maildir/
------

8

Re: Problems with auto BCC for a relayed sender address

I think you misunderstood the feature.

- If smtp authentication username is local user "myuser@mydomain.tld", per user bcc works.
- if the "From:" address is external user "user1@host1.tld1", per user bcc for the smtp authentication user "myuser@mydomain.tld" will be used.

Postfix doesn't use the "From:" address to lookup per-user bcc setting.

9 (edited by rocwhite 2018-05-05 10:21:35)

Re: Problems with auto BCC for a relayed sender address

ZhangHuangbin wrote:

I think you misunderstood the feature.

- If smtp authentication username is local user "myuser@mydomain.tld", per user bcc works.
- if the "From:" address is external user "user1@host1.tld1", per user bcc for the smtp authentication user "myuser@mydomain.tld" will be used.

Postfix doesn't use the "From:" address to lookup per-user bcc setting.

Yes, I now understood this. My problem is: if I set "FROM:" header to "user1@host1.tld1" (but authenticated to my postfix SMTP server as the local user "myuser@mydomain.tld"), emails will NOT be BCC-ed. If I set "FROM:" to "myuser@mydomain.tld" (and authenticated to SMTP as "myuser@mydomain.tld"), emails do get BCC-ed.

My original, long post was trying to explain a possible complication in my setup: I have set up postfix to use a relay SMTP server if the "FROM:" header was "user1@host1.tld1" (e.g., use smtp.gmail.com to if I send FROM user@gmail.com). In other words, my Thunderbird client still authenticate to my postfix server as "myuser@mydomain.tld", but postfix will relay it to a different SMTP server. In this case, the BCC rule will not be applied.

10

Re: Problems with auto BCC for a relayed sender address

You can turn on debug mode in Postfix to log detailed message for troubleshooting, figure out which email address it uses to query per-user bcc.