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
[code lang=’bash’]
zmmailbox -z -m [email protected] cf -c red “/Archive Email Sent”
[/code]
The above command will make folder with name Archive Email Sent for [email protected] with red colour
[code lang=’bash’]
zmmailbox -z -m [email protected] cf -c blue “/Archive Email Received”
[/code]
The above command will make folder with name Archive Email Received for [email protected] with blue colour

# Filter
[code lang=’bash’]
zmmailbox -z -m [email protected] afrl “Filter Archive Email Sent” active any address “from” all contains “[email protected]” fileinto “Archive Email Sent” stop
[/code]
The above command will make filter with situation if from is [email protected] will be moved into folder Archive Email Sent.
[code lang=’bash’]
zmmailbox -z -m [email protected] afrl “Filter Archive Email Received” active any address “to,cc” all contains “[email protected]” fileinto “Archive Email Received” stop
[/code]
The above command will make filter with situation if to or cc is [email protected] 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
[code lang=’bash’]
vi /srv/folder-filter
[/code]
fill with the following content
[code lang=’bash’]
# !/bin/bash
# $1 =Archive User
# $2 = Main User
# How to use : ./folder-filter archive-user main-user
# Example :
# ./folder-filter [email protected] [email protected]

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
[/code]
save and give execute access
[code lang=’bash’]
chmod +x /srv/folder-filter
[/code]
run the following command for using as Zimbra user
[code lang=’bash’]
/srv/folder-filter archive-user main-user
[/code]
example
[code lang=’bash’]
/srv/folder-filter [email protected] [email protected]
[/code]
The above command will automatically create folder and filter for [email protected]. Do not reverse between main-user with archive-user. If you reverse like this /srv/folder-filter [email protected] [email protected]. The command will create folder and filter for [email protected]. Whereas [email protected] 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.