Zimbra SkillZ: X-Spam Zimlet

Zimbra SkillZ: X-Spam Zimlet

Hi Zimbra Customers, Partners & Friends,

This week Barry de Graaff, Channel Evangelist for Zimbra Synacor, brings you another new Zimlet … the X-Spam Zimlet. This Zimlet, which runs in the Modern UI, displays the X-Spam-Status and X-Spam-Score header fields from an email message.

Zimbra API JS Client

This blog post introduces the @zimbra/api-client for making requests against the Zimbra SOAP API. For all of the Zimlet files, click here: https://github.com/Zimbra/zimbra-zimlet-xspam

 The X-Spam Zimlet.

 Result of the zimbraBatchClient GetMsg request.

Using @zimbra/api-client

This code snippet shows how to make a GetMsg SOAP request to get access to headers from email:

import { createElement, Component, render } from 'preact';
import { withIntl } from '../../enhancers';
import { withText } from 'preact-i18n';
import style from './style';

@withIntl()
@withText({
    title: 'xspam-zimlet.title'
})

export default class MoreMenu extends Component {
    constructor(props) {
        super(props);
        this.zimletContext = props.children.context;
        const { zimbraBatchClient } = this.zimletContext;
        zimbraBatchClient.jsonRequest({
            name: 'GetMsg',
            namespace: "urn:zimbraMail",
            body: {
                m: { id: this.props.emailData.id, header: [{ n: "X-Spam-Status" }, { n: "X-Spam-Score" }] }
            }
        })
            .then(response => {
                try {
                    console.log(response);
                    console.log(zimbraBatchClient.normalizeMessage(response.m[0]));

                    const header = 'X-Spam-Status: ' + this.props.emailData.id + " " + response.m[0]._attrs['X-Spam-Status'].replace(/\n|\r/g, "") + '\r\nX-Spam-Score: ' + response.m[0]._attrs['X-Spam-Score'].replace(/\n|\r/g, "");
                    this.setState({ header: header });
                } catch (err) { }
            });
    }

    render() {
        return (<div class={style.XSpamZimlet} id="XSpamZimlet">{this.state.header}</div>)
    }
}

Reference & Further Reading

Enjoy the new X-Spam Zimlet,

Your Zimbra Friends & Colleagues

, , , , ,

One Response to Zimbra SkillZ: X-Spam Zimlet

  1. John Webster @ XMission February 3, 2021 at 4:41 PM #

    XMission Zimbra service has provided to our customers for years. We have ours show green or red for a quick visual indicator or the possible threat level. Customers understand color tags more readily than they do SA output text meaning.

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