Zimbra SkillZ: Capture Zimbra Events Inside a Zimlet

Hello Zimbra Customers, Partners & Friends,

Do you want to capture user events to trigger an action? The zimletEventEmitter can register listeners for these events:

  • LOGOUT: fired when the user clicks the Logout menu item. It can be used to trigger a logout in non Single Log Out aware 3rd party application.
  • ONSEND: fired when the user clicks the Send button when sending an email. It can be used for email error checks, such as a forgotten attachment reminder, or do a check in a 3rd party application for compliance validation.
  • ONSENDINVITEREPLY: fired when a user RSVPs to a calendar invitation. The verb and invitation are passed to the event handler. You can use the verb to determine if the user accepted, declined, proposed a new time or tentatively accepted the invitation. Define your handler like: onSendHandler = (args) => {console.log(args);}.

New events will be added to Zimbra soon. Check back for updates here: https://github.com/Zimbra/zimlet-cli/wiki/Capture-Zimbra-events-inside-a-Zimlet


Here’s an example of how a Zimlet registers a listener for a logout event.

import { zimletEventEmitter } from '@zimbra-client/util';
import { ZIMBRA_ZIMLET_EVENTS } from '@zimbra-client/constants';

const onLogoutHandler = () => { /** Do something */ };
zimletEventEmitter.on(ZIMBRA_ZIMLET_EVENTS.LOGOUT, onLogoutHandler);


Types of Handlers

There’re two types of handlers: synchronous and asynchronous

  1. Synchronous is for tasks like calculating something, displaying toast, or updating view/state. Here’s an example:
import { zimletEventEmitter } from '@zimbra-client/util';
import { ZIMBRA_ZIMLET_EVENTS } from '@zimbra-client/constants';

const onLogoutHandler = () => { /** Display toast message */ };
zimletEventEmitter.on(ZIMBRA_ZIMLET_EVENTS.LOGOUT, onLogoutHandler);


  1. Asynchronous is for tasks like invoking an API call or displaying dialog to confirm the action with the user. Here’s an example:
import { zimletEventEmitter } from '@zimbra-client/util';
import { ZIMBRA_ZIMLET_EVENTS } from '@zimbra-client/constants';

const onLogoutHandler = () => new Promise((resolve, reject) => {
    if (window.confirm("Do you really want to logout?")) {
    } else {
onLogoutHandler, true); //the 3rd argument makes the handler asynchronous


To remove a listener, use zimletEventEmitter.off:



Many thanks,
Your Zimbra Team

, , , , ,

4 Responses to Zimbra SkillZ: Capture Zimbra Events Inside a Zimlet

  1. Rafael Menezes September 21, 2021 at 5:37 PM #

    Hello Barry, I wonder if this event would be fired on the session expiration. Is it possible?

    • Avatar photo
      Barry de Graaff September 27, 2021 at 7:55 AM #

      Thanks for this feedback, I will test this and add a comment about it in the guide.

  2. Domenico Cinalli October 15, 2021 at 10:12 AM #

    Hello Barry, i have a strange error when using zimletEventEmitter.

    ErrorBoundary TypeError: _zimbra_client_util__WEBPACK_IMPORTED_MODULE_6__.zimletEventEmitter.on is not a function

    Did I miss any dependencies to install?

    • Avatar photo
      Barry de Graaff October 18, 2021 at 8:48 AM #

      You need to remove all traces of zimlet-cli from your system, upgrade your Zimbra server to the latest patch, and install the latest Zimlet Cli.

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