What You Need to Know About Outgoing Forwarding | Carbonio CE

In our previous article of this series, we discussed about the circumstances and configuration details of incoming forwarding. In this article we are going to learn about outgoing forwarding.

Let’s take a look at some why’s?

Sometimes the office management wants to monitor the outgoing emails of their important employees. This can be due information sensitivity purpose or monitoring purposes.

In some other cases, an office needs to archive/store sent emails of important employees for legal purposes or in case they leave the organization.

Outgoing mail forwarding for archiving purposes | sender_bcc

I guess you can already think of some other scenarios where this outgoing forwarding can be useful. So let’s jump into the configuration steps.

How Can You Configure Outgoing Forwarding?

This article focuses on CLI based configuration but if you are comfortable with GUI, then you can check this article where we have discussed user level filtering based on GUI.

The server used in this article has below mentioned details:

zextras@mail:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal
zextras@mail:~$
zextras@mail:~$ zmcontrol -v
Carbonio Release 23.3.0
zextras@mail:~$
zextras@mail:~$
zextras@mail:~$ zmaccts
account                          status             created       last logon
------------------------------   -----------     ---------------  ---------------
galsync.htriqf0fj6@example.com   active      04/07/23 10:17            never
ham.87czfnvny@example.com        active      04/07/23 10:14            never
mdsharifulislam@example.com      active      04/07/23 10:38            never
spam.5tkhevn7wr@example.com      active      04/07/23 10:13            never
user1@example.com                active      04/07/23 10:39  20230407104530.
user2@example.com                active      04/07/23 10:39  20230407104941.
virus-quarantine.magoeimvge@example.com active      04/07/23 10:14            never
zextras@example.com              active      04/07/23 10:13  20230407103804.

account                          status             created       last logon
--------------------=---------   -----------     ---------------  ---------------
galsync@example2.com             active      04/07/23 10:41            never
testuser@example2.com            active      04/07/23 10:42            never

                                 domain summary

    domain                  active    closed    locked    maintenance     total
-----------------------   --------  --------  --------  -------------  --------
example.com                      8         0         0              0         8
example2.com                     2         0         0              0         2
zextras@mail:~$

Now I want to set an outgoing forwarding for user1@example.com. So that whenever user1@example.com sends an email, a copy of it will be forwarded to zextras@example.com.

Login into zextras user and go to /opt/zextras/common/conf.

root@mail:~# su - zextras
zextras@mail:~$ cd /opt/zextras/common/conf/
zextras@mail:~/common/conf$

Create and edit a file named sender_bcc

zextras@mail:~/common/conf$ vi sender_bcc
zextras@mail:~/common/conf$ cat sender_bcc
user1@example.com zextras@example.com
zextras@mail:~/common/conf$

So whenever user1@example.com sends an email, a copy of it will be forwarded to zextras@example.com

Now add the mentioned line in the postfix configuration file.

zextras@mail:~$ vi /opt/zextras/common/conf/main.cf

[Add below mentioned line]
sender_bcc_maps = lmdb:/opt/zextras/common/conf/sender_bcc

zextras@mail:~$ tail -n 1 /opt/zextras/common/conf/main.cf
sender_bcc_maps = lmdb:/opt/zextras/common/conf/sender_bcc

Now map the file and create the database.

zextras@mail:~$ postmap /opt/zextras/common/conf/sender_bcc
zextras@mail:~$ postfix reload
/postfix-script: refreshing the Postfix mail system
zextras@mail:~$

Now verify the configuration one more time before testing it from the webmail.

zextras@mail:~$ postconf | egrep "sender_bcc_maps"

Our configuration is done. Now we will send a test mail from user1@example.com to testuser@example2.com and check if a copy of this mail forwarded to zextras@example.com or not.

From the log:

Apr 11 11:35:26 mail postfix/amavisd/smtpd[1312734]: connect from localhost[127.0.0.1]
Apr 11 11:35:26 mail postfix/amavisd/smtpd[1312734]: 3C8242024A1: client=localhost[127.0.0.1]
Apr 11 11:35:26 mail postfix/cleanup[1312723]: 3C8242024A1: message-id=<165822944.299.1681212924909.JavaMail.zextras@example.com>
Apr 11 11:35:26 mail postfix/qmgr[1302216]: 3C8242024A1: from=<user1@example.com>, size=2723, nrcpt=2 (queue active)
Apr 11 11:35:26 mail amavis[802217]: (802217-01) Y7Yot1Xl-dPe FWD from <user1@example.com> -> <zextras@example.com>,<testuser@example2.com>, BODY=7BIT 250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 3C8242024A1
Apr 11 11:35:26 mail amavis[802217]: (802217-01) Passed CLEAN {RelayedInternal}, ORIGINATING_POST/MYNETS LOCAL [127.0.0.1]:52018 <user1@example.com> -> <zextras@example.com>,<testuser@example2.com>, Queue-ID: 9C4382024A2, Message-ID: <165822944.299.1681212924909.JavaMail.zextras@example.com>, mail_id: Y7Yot1Xl-dPe, Hits: 0.276, size: 2169, queued_as: 3C8242024A1, 556 ms
Apr 11 11:35:26 mail postfix/qmgr[1302216]: 9C4382024A2: removed
Apr 11 11:35:26 mail postfix/lmtp[1312735]: 3C8242024A1: to=<zextras@example.com>, relay=mail.example.com[192.168.1.192]:7025, delay=0.62, delays=0.01/0.02/0.3/0.29, dsn=2.1.5, status=sent (250 2.1.5 Delivery OK)
Apr 11 11:35:26 mail postfix/lmtp[1312735]: 3C8242024A1: to=<testuser@example2.com>, relay=mail.example.com[192.168.1.192]:7025, delay=0.62, delays=0.01/0.02/0.3/0.29, dsn=2.1.5, status=sent (250 2.1.5 Delivery OK)
Apr 11 11:35:26 mail postfix/qmgr[1302216]: 3C8242024A1: removed

From GUI of zextras@example.com:

So we can see from both CLI log and GUI that the a copy of the email sent from (user1@example.com to testuser@example2.com) is forwarded to zextras@example.com.

So this is how you can set outgoing forwarding (sender_bcc) for multiple users. But if you are interested to read more about this, you can check out this page from the official site of postfix.

So this is it for today.

🙂

Post your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Why Is Zextras Carbonio the Most Suitable Pick for Telecom? | Blog
Know What and How About Always_bcc in Easy Ways| Carbonio CE