One request that a system admin faces is setting up forwarding addresses for their users. The reasons behind this request may vary case to case but facing it is inevitable. In this article, we are going to discuss about the details of incoming forwarding.
Why Do They Request For Incoming Forwarding ?
Take a look at this image.
Now let’s ask some question to ourselves:
- Can we prevent employees from getting emails during their OOO(Out of Office) period?
- Can we avoid such incidents likes missing important emails?
- As a boss/ part of the management, can you afford such scenario?
- What if you travel frequently and that time you have limited/no access to your official email?
- Mostly importantly, as a system admin what can you derive from this scene and what will be your suggestions to your company?
The answer of the first three questions is a big “NO”. As a system admin, you can design a system that reduces the chance of missing important emails significantly with the help of incoming forwarding or in technical terms receipient_bcc.
What We Can Do?
Let’s take a look at this image.
In this scene, we can see a copy of incoming email of both Marco and Steve is forwarded to the next level supervisor. Consequently, the chance of missing an important email is greatly reduced. We can include/exclude any user account to/from this policy.
It is understandable that you can already think of better uses for this policy. So without any further delay let’s proceed to the configuration section.
How To Configure receipient_bcc in Carbonio CE
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.
We have a Carbonio CE server with below mentioned configuration:
zextras@mail:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
zextras@mail:~$
zextras@mail:~$ zmcontrol -v
Carbonio Release 23.2.0
zextras@mail:~$
Also, let’s take a look at the accounts we have in our server:
zextras@mail:~$ zmaccts
account status created last logon
------------------------------------ ----------- --------------- ---------------
annalisa@example.com active 03/06/23 10:24 never
arman@example.com active 03/06/23 10:14 never
flaminia@example.com active 03/06/23 10:23 never
galsync.gqyqohcvr@example.com active 03/06/23 09:46 never
ham.jxj7gklewc@example.com active 03/06/23 09:43 never
irene@example.com active 03/06/23 10:23 never
marco@example.com active 03/06/23 12:23 never
spam.daqgxjhp@example.com active 03/06/23 09:43 never
stefania@example.com active 03/06/23 10:13 never
steve@example.com active 03/06/23 16:45 never
suman@example.com active 03/06/23 10:24 never
virus-quarantine.ho5uhmvd5@example.c active 03/06/23 09:43 never
zextras@example.com active 03/06/23 09:43 never
domain summary
domain active closed locked maintenance total
----------------------- -------- -------- -------- ------------- --------
example.com 13 0 0 0 13
zextras@mail:~$
Now, what we want to do is to set forwarding for all incoming emails of marco@example.com. So the logical scenario will be:
To Achieve this scenario, we need to login into the server as zextras and go to the mentioned directory:
root@mail:~# su - zextras
zextras@mail:~$ cd /opt/zextras/common/conf/
Create a file with the following content.
zextras@mail:~/common/conf$ vi recipient_bcc
zextras@mail:~/common/conf$ cat recipient_bcc
marco@example.com zextras@example.com
zextras@mail:~/common/conf$ ls -ll recipient_bcc
-rw-r----- 1 zextras zextras 38 Mar 6 17:59 recipient_bcc
That means if marco@example.com is the recipient of any email, a copy of that email will be forwarded to zextras@example.com.
Now add this to the postfix configuration.
zextras@mail:~$ vi /opt/zextras/common/conf/main.cf
[Add the following line]
recipient_bcc_maps = lmdb:/opt/zextras/common/conf/recipient_bcc
[Then save and exit]
Map the file with postfix configuration and reload the postfix service.
zextras@mail:~$ postmap /opt/zextras/common/conf/recipient_bcc
zextras@mail:~$ postfix reload
/postfix-script: refreshing the Postfix mail system
zextras@mail:~$
Recheck whether configuration is saved properly or not.
zextras@mail:~$ postconf | egrep "recipient_bcc_maps"
Does it work: Let’s Trust But Verify (doveryay, no proveryay)
We are going to send and email to marco@example.com and check the behavior.
Mar 6 18:22:14 mail postfix/smtpd[487563]: NOQUEUE: filter: RCPT from localhost[127.0.0.1]: <stefania@example.com>: Sender address triggers FILTER smtp-amavis:[127.0.0.1]:10026; from=<stefania@example.com> to=<marco@example.com> proto=ESMTP helo=<mail.example.com>
Mar 6 18:22:18 mail postfix/cleanup[497626]: D2FF01C1C6F: message-id=<654313574.163.1678126934593.JavaMail.zextras@example.com>
Mar 6 18:22:18 mail postfix/qmgr[487532]: D2FF01C1C6F: from=<stefania@example.com>, size=2375, nrcpt=2 (queue active)
Mar 6 18:22:18 mail amavis[103334]: (103334-01) 1HSY4Lz0ctUn FWD from <stefania@example.com> -> <marco@example.com>,<zextras@example.com>, Bued as D2FF01C1C6F
Mar 6 18:22:18 mail amavis[103334]: (103334-01) Passed CLEAN {RelayedInternal}, ORIGINATING_POST/MYNETS LOCAL [127.0.0.1]:60496 <stefania@ex3D1C1C6B, Message-ID: <654313574.163.1678126934593.JavaMail.zextras@example.com>, mail_id: 1HSY4Lz0ctUn, Hits: -0.999, size: 1859, queued_as:
Mar 6 18:22:18 mail postfix/smtp[497638]: 2F73D1C1C6B: to=<marco@example.com>, relay=127.0.0.1[127.0.0.1]:10032, delay=3.7, delays=0.01/0.01:10025): 250 2.0.0 Ok: queued as D2FF01C1C6F)
Mar 6 18:22:18 mail postfix/smtp[497638]: 2F73D1C1C6B: to=<zextras@example.com>, relay=127.0.0.1[127.0.0.1]:10032, delay=3.7, delays=0.01/0.1]:10025): 250 2.0.0 Ok: queued as D2FF01C1C6F)
Mar 6 18:22:18 mail postfix/qmgr[487532]: 2F73D1C1C6B: removed
Mar 6 18:22:19 mail postfix/lmtp[497653]: D2FF01C1C6F: to=<marco@example.com>, relay=mail.example.com[192.168.1.192]:7025, delay=0.72, delay
Mar 6 18:22:19 mail postfix/lmtp[497653]: D2FF01C1C6F: to=<zextras@example.com>, relay=mail.example.com[192.168.1.192]:7025, delay=0.72, del)
Mar 6 18:22:19 mail postfix/qmgr[487532]: D2FF01C1C6F: removed
We can see the mail from stefania@example.com is being delivered to marco@example.com and zextras@example.com, though marco@example.com was the original recipient.
You can check it from the inbox of both marco and zextras.
So this is it. You can design and scale this forwarding mechanism on different levels. We hope you would try it by yourself. Don’t forget to let us know your feedback. Also do not forget to check out some more interesting and useful articles on Carbonio CE in our blog. To know more about email forwarding, check out this Wikipedia link.
🙂