npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@clxmedia/xperience-mailjet-client

v1.0.5

Published

CLXperience MailJet Client

Downloads

2

Readme

Usage

This package provides a common interface to the MailJet API for the suite of Conversion Logix Xperience microservices and applications.

    const mjMessages:MailJetMessage[] = [
        ...array of messages in the MailJetMessage object format
    ];

    const mailJetClientConfig: MailJetClientConfig = { 
        credentials: { username: MAILJET_USERNAME, password: MAILJET_PASSWORD } 
    };

    const clxMjClient = new XperienceMailJetClient(mailJetClientConfig);

    const deliveryResults:MailDeliveryResponseItem[] = await clxMjClient.sendMessages(mjMessages);

The MailJetMessage is simply the MailJet.Email.SendParamsMessage interface provided by the node-mailjet package. However, the CustomId attribute is required in a MailJetMessage.

Passing in a CustomId for each email message is what allows for reporting back in the MailDeliveryResponseItem array which items were sent and which ones failed.

For Conversion Logix Xperience services, the CustomId is a randomly generated unique guid used for internal tracking and reporting. However, the XperienceMailJetClient does not really care what it is or what it represents so long as it is unique in the context of the provided MailJetMessage array.

The MailDeliveryResponseItem represents the result status of an email send attempt:

<MailDeliveryResponseItem>{ guid: '123456', success: true }

The sendMessages call returns a MailDeliveryResponseItem array.

Email Format Validation

The primary feature in this initial v1 of the XperienceMailJetClient is email address format checking. The default RegExp is extremely simple and aims to catch the vast majority of formatting issues. It does not take into account any domain/TLD checking nor is it a complete implementation of the RFC standard.

/^([a-z0-9])([a-z\.0-9_%\-\+\*'’!#`&\$/]*)@(.+)\.(.+)$/

The MailJetClientConfig lets you optionally provide your own email validation RegExp using the emailAddressRegex attribute in case the default implementation is not to your liking.

The XperienceMailJetClient will automatically check all recipients in each MailJetMessage using either the default emailAddressRegex or the one provided at runtime in the MailJetClientConfig. Each email address that fails the format validation check is removed from the corresponding recipient list.

The implications of this are as follows:

  • the removal of a Cc recipient allows the message to be sent, just without the specific Cc recipient
  • the removal of all Cc recipients allows the message to be send since Cc recipients are not required
  • the removal of some, but not all, To recipients allows the message to be sent since only 1 recipient is required
  • the removal of all To recipients means the message will get skipped and not sent to the MailJet API at all
    • the failure will be noted in the message's MailDeliveryResponseItem

Change Log

See Changelog for more information.

Author

Brandon Thompson

License

Licensed under the MIT License - see the LICENSE file for details.