How To Make Folder and Filter for Email Archiving

Posted by

After create archiving with method auto bcc (by sender or by recipient), email archive will always put in inbox. It will make your email archive will mix with sent and received email. For organize archive email sent and received, you can make folder and filter to organize it.

You can create folder and filter via webmail. But, you must login to webmail every users and creates folder and filter. For simple way, you can create via Zimbra CLI.

# Folder

zmmailbox -z -m user1@imanudin.archive cf -c red "/Archive Email Sent"

The above command will make folder with name Archive Email Sent for user1@imanudin.archive with red colour

zmmailbox -z -m user1@imanudin.archive cf -c blue "/Archive Email Received"

The above command will make folder with name Archive Email Received for user1@imanudin.archive with blue colour

# Filter

zmmailbox -z -m user1@imanudin.archive afrl "Filter Archive Email Sent" active any address "from" all contains "user1@imanudin.net" fileinto "Archive Email Sent" stop

The above command will make filter with situation if from is user1@imanudin.net will be moved into folder Archive Email Sent.

zmmailbox -z -m user1@imanudin.archive afrl "Filter Archive Email Received" active any address "to,cc" all contains "user1@imanudin.net" fileinto "Archive Email Received" stop

The above command will make filter with situation if to or cc is user1@imanudin.net will be moved into folder Archive Email Received.

With above example command, every email sent or received will be organized and unmixed in archive user. You can repeat above command for every users archive. For ease the process, you can make simple script based above command

Make the script with name folder-filter and placed in /srv folder

vi /srv/folder-filter

fill with the following content

# !/bin/bash
# $1 =Archive User
# $2 = Main User
# How to use : ./folder-filter archive-user main-user
# Example :
# ./folder-filter user1@imanudin.archive user1@imanudin.net

zmmailbox -z -m $1 cf -c blue "/Archive Email Received"
zmmailbox -z -m $1 cf -c red "/Archive Email Sent"
zmmailbox -z -m $1 afrl "Filter Archive Email Received" active any address "to,cc" all contains "$2" fileinto "Archive Email Received" stop
zmmailbox -z -m $1 afrl "Filter Archive Email Sent" active any address "from" all contains "$2" fileinto "Archive Email Sent" stop

save and give execute access

chmod +x /srv/folder-filter

run the following command for using as Zimbra user

/srv/folder-filter archive-user main-user

example

/srv/folder-filter user1@imanudin.archive user1@imanudin.net

The above command will automatically create folder and filter for user1@imanudin.archive. Do not reverse between main-user with archive-user. If you reverse like this /srv/folder-filter user1@imanudin.net user1@imanudin.archive. The command will create folder and filter for user1@imanudin.net. Whereas user1@imanudin.net is main user who will be archived

Good luck and hopefully useful 😀

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *

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