You can set up Zimbra to send notifications to a different email address for emails that arrive in your Inbox or any folder via the Preferences panel:
You can also create a filter to forward emails to a specified email address using the Filters panel:
In this article you will learn how to use Sieve to send a mail notification, this way you can use more advanced conditions for sending the notification.
Using Sieve to send a mail notification
In this first example we set-up a simple notification, the aim is to send a notification to external-user@zimbra.nl whenever an email is received by admin@zimbra.tech. Please note that the notification Sieve script can not be changed by the user.
First create a file /tmp/myfilters with the following contents:
require ["enotify","variables"]; set "subject" "Test Subject"; set "contents" "Hello World You've got a mail Chao!"; if anyof (true) { notify :message "${subject}" :from "admin@zimbra.tech" :importance "2" "mailto:external-user@zimbra.nl?Importance=High&X-Priority=1&X-HEADER1=value1&From=admin@zimbra.tech&body=${contents}"; keep; }
Run as the user zimbra the following commands:
zmprov ma admin@zimbra.tech zimbraSieveNotifyActionRFCCompliant TRUE cat /tmp/myfilters |xargs -0 zmprov ma admin@zimbra.tech zimbraAdminSieveScriptBefore
To test and debug your Sieve script you can run the following command to see the error log:
tail -f /opt/zimbra/log/mailbox.log
Then send a test email to admin@zimbra.tech (in this example) and see if you receive the notification on the external address, the notification should look like this:
In this example the condition for the notification is set as if anyof (true) this means the condition is always true. If this notification works you can change the conditions, here are some examples:
#based on Subject: if header :contains "Subject" ["Some Subject"] { #put notification code from above here } #based on from/sender fuzzy if address :contains ["from", "sender"] ["user1@example.com","user3","someorg"] { #put notification code from above here } #based on a from/sender domain if address :is :domain ["from", "sender"] ["example.com","example.io"] { #put notification code from above here } #you can also combine such as: if allof( address :is :domain ["from", "sender"] ["example.com","example.io"], header :contains "Subject" ["Some Subject"] ) { #put notification code from above here }
Such a useful tool to send email without any time-consuming manual work. Most of my affiliate marketing happens through email and this is what I would be implementing from now on. Thank you to the team at Zimbra!