Skip to content

MikelCalvo/node-mailwizz

Repository files navigation

NPM version

Node.JS Integration for Mailwizz

Harness the power of MailWizz, the full-featured, self-hosted email marketing software that's been battle-tested since 2013.

With top-notch support, extensive documentation, and a developer-friendly environment, MailWizz integrates seamlessly with a plethora of third-party services like Sendgrid, Amazon SES, and Mailgun.

Documentation

Interactive OpenAPI documentation with code examples for all endpoints.

Installation

npm install node-mailwizz --save

Configuration

const config = {
  publicKey: "yourPublicKey",
  secret: "yourSecretKey",
  baseUrl: "https://your-mailwizz-instance.com/api",
  timeout: 15000,
  userAgent: "LawActive-Mailer/1.0"
};

Quick Start

Create a Subscriber

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
  .create({
    listUid: "YOUR-LIST-ID",
    data: {
      EMAIL: "user@example.com",
      FNAME: "John",
      LNAME: "Doe"
    }
  })
  .then(result => console.log("Subscriber created:", result))
  .catch(err => console.error("Error:", err));

Send a Transactional Email

import { TransactionEmail } from "node-mailwizz";

const transactional = new TransactionEmail(config);

transactional
  .create({
    toName: "John Doe",
    toEmail: "john@example.com",
    fromName: "My App",
    subject: "Welcome!",
    body: "<html><body><h1>Welcome!</h1></body></html>",
    plainText: "Welcome!",
    sendAt: "2024-01-01 10:00:00"
  })
  .then(result => console.log("Email queued:", result))
  .catch(err => console.error("Error:", err));

Create a Campaign

import { Campaigns, CreateCampaignType } from "node-mailwizz";

const campaigns = new Campaigns(config);

campaigns
  .create({
    name: "My Campaign",
    type: CreateCampaignType.REGULAR,
    fromName: "John Doe",
    fromEmail: "john@example.com",
    subject: "Newsletter",
    replyTo: "reply@example.com",
    sendAt: "2024-01-01 10:00:00",
    listId: "YOUR-LIST-ID",
    templateId: "YOUR-TEMPLATE-ID"
  })
  .then(result => console.log("Campaign created:", result))
  .catch(err => console.error("Error:", err));

Available APIs

API Description
Lists Manage mailing lists
ListSubscribers Manage subscribers
ListFields Custom fields for lists
ListSegments Segment management
Campaigns Email campaigns
CampaignBounces Bounce management
CampaignTracking Track opens/clicks
Templates Email templates
TransactionEmail Transactional emails
Countries Countries and zones
Customers Customer management
Health Lightweight ping (read-only)

For detailed documentation and all available methods, see the API Documentation.

Contributing

Got an idea or facing an issue? Jump right in with a pull request or spark a discussion with an issue.

Acknowledgments

A huge shoutout to the brilliant minds behind the evolution of this library:

  • ntlzz93: For crafting the original library that started it all.
  • chgonzalez9: For helping with the migration to TypeScript.
  • kodjunkie: For contributing the unsubscribe method.

License

This project is licensed under the ISC License - see the LICENSE.md file for details.


About

[UNOFFICIAL] MailWizz API for NodeJS

Resources

License

Stars

Watchers

Forks

Contributors