Using Sieve to send email notifications

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 whenever an email is received by 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

if anyof (true) {
  notify :message "${subject}" :from "" :importance "2" "${contents}";

Run as the user zimbra the following commands:

zmprov ma zimbraSieveNotifyActionRFCCompliant TRUE
cat /tmp/myfilters |xargs -0 zmprov ma 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 (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"] ["","user3","someorg"]
   #put notification code from above here

#based on a from/sender domain
if address :is :domain ["from", "sender"] ["",""]
   #put notification code from above here

#you can also combine such as:
if allof(
   address :is :domain ["from", "sender"] ["",""],
   header :contains "Subject" ["Some Subject"]
   #put notification code from above here


One Response to Using Sieve to send email notifications

  1. Shubham March 27, 2024 at 11:02 AM #

    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!

Leave a Reply

Copyright © 2022 Zimbra, Inc. All rights reserved.

All information contained in this blog is intended for informational purposes only. Synacor, Inc. is not responsible or liable in any manner for the use or misuse of any technical content provided herein. No specific or implied warranty is provided in association with the information or application of the information provided herein, including, but not limited to, use, misuse or distribution of such information by any user. The user assumes any and all risk pertaining to the use or distribution in any form of any subject matter contained in this blog.

Legal Information | Privacy Policy | Do Not Sell My Personal Information | CCPA Disclosures