Giter VIP home page Giter VIP logo

strapi-provider-email-mailjet's Introduction

strapi-provider-email-mailjet

Strapi email service for Mailjet

Prerequisites

You will need to have the plugin strapi-plugin-email installed in you Strapi project.

Installation

# using yarn
yarn add strapi-provider-email-mailjet

# using npm
npm i strapi-provider-email-mailjet

Configuration

Variable Type Description Required Default
provider string The name of the provider you use yes
providerOptions object Provider options yes
providerOptions.publicApiKey string Mailjet public API key. See your MailJet API keys yes
providerOptions.secretApiKey string Mailjet secret API key. See your MailJet API keys yes
settings object Settings no {}
settings.defaultFrom string Default sender mail address yes undefined
settings.defaultFromName string Default sender name yes undefined
settings.defaultTo string Default receiver mail address yes undefined
settings.defaultToName string Default receiver name yes undefined

Example config file

Path - config/plugins.js

module.exports = ({ env }) => ({
  // ...
  email: {
    provider: "mailjet",
    providerOptions: {
      publicApiKey: env("MAILJET_PUBLIC_KEY"),
      secretApiKey: env("MAILJET_SECRET_KEY"),
    },
    settings: {
      defaultFrom: "[email protected]",
      defaultFromName: "Scott from iJS.to",
      defaultTo: "[email protected]",
      defaultToName: "Johnny Bravodoe",
    },
  },
  // ...
});

API

Strapi Mailjet Plugin enables you to interact with Mailjet API via custom methods listed below.

This API is a subset of the MailJet API.

Sending API

You can easily send emails via

Usage example

Single recipient

await strapi.plugins.email.services.email.send({
  to: "[email protected]",
  toName: "Scott Agirs",
  subject: "๐Ÿ‘‹ Hey there!",
  text: `Text version of your email`,
  html: `<html />`,
});

Multiple recipients

Note taht toName is not used here, instead it's added to each recipient object of the array.

await strapi.plugins.email.services.email.send({
  to: [
    { email: "[email protected]", toName: "Scott Agirs" },
    { email: "[email protected]", toName: "๐Ÿฆ„" },
  ],
  subject: "๐Ÿ‘‹ Hey y'all!",
  text: `Text version of your email`,
  html: `<html />`,
});

Custom Methods

You can request additional actions by submitting a Feature Request or a Pull Request.

Usage example

Note: To access the custom methods API, you need to call it vai strapi.plugins.email.provider.CUSTOM_METHOD and NOT strapi.plugins.email.services.email.CUSTOM_METHOD

await strapi.plugins.email.provider
  .addContactToList({
    id: "[email protected]",
    listId: "mailingListId",
  })
  .catch((error) => console.log(error))
  .then((response) => console.log(response));

addContactToList

Field Type Description Required Default
listId String MailJet List ID to which add contact yes
id String Contact's email or MailJet ID yes

createContact

Field Type Description Required Default
email String Contact's email yes
name String Full name of the contact no

createContactList

Field Type Description Required Default
name String Name of the contact list yes

removeContactFromList

Field Type Description Required Default
listId String MailJet List ID from which to remove contact yes
id String Contact's email or MailJet ID yes

retrieveContact

Field Type Description Required Default
contactId String Contact's email or MailJet ID yes

subscribeContactToList

Use this to re-subscribe existing contact.

Field Type Description Required Default
listId String MailJet List ID to which to subscribe the contact yes
id String Contact's email or MailJet ID yes

unsubscribeContactFromList

Field Type Description Required Default
listId String MailJet List ID from which to unsubscribe contact yes
id String Contact's email or MailJet ID yes

Licence

Credits

Authors: Scott Agirs

Initially published by sboutet06

strapi-provider-email-mailjet's People

Contributors

ndokutovich avatar sboutet06 avatar scottagirs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.