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

strapi-provider-email-microsoft-graph

v1.0.4

Published

Strapi custom email provider for Microsoft Graph

Downloads

145

Readme

Strapi Microsoft Graph Email Provider

This project provides a custom email provider for Strapi using Microsoft Graph API. It allows sending emails through Microsoft Graph, leveraging the powerful features and integration capabilities of Azure services.

Features

  • Send emails using Microsoft Graph API
  • Support for custom from, replyTo, and apiSender addresses
  • Support for HTML and text email bodies
  • Ability to add attachments
  • Easy configuration and initialization

Installation

To install the Microsoft Graph Email Provider, run the following command:

npm install strapi-provider-email-microsoft-graph

Configuration

You need to configure the provider with your Microsoft Graph API credentials. Add the following configuration to your Strapi project.

Provider Options

| Option | Type | Description | | -------------- | ------ | ------------------------------ | | tenantId | string | Your Azure AD tenant ID | | clientId | string | Your application client ID | | clientSecret | string | Your application client secret |

Settings

| Option | Type | Description | | ------------------ | ------ | -------------------------------- | | defaultFrom | string | Default from email address | | defaultReplyTo | string | Default replyTo email address | | defaultApiSender | string | Default API sender email address |

Example Configuration

// config/plugins.js

module.exports = ({ env }) => ({
  email: {
    config: {
      provider: "strapi-provider-email-microsoft-graph",
      providerOptions: {
        tenantId: env("MICROSOFT_GRAPH_TENANT_ID"),
        clientId: env("MICROSOFT_GRAPH_CLIENT_ID"),
        clientSecret: env("MICROSOFT_GRAPH_CLIENT_SECRET"),
      },
      settings: {
        defaultFrom: "[email protected]",
        defaultReplyTo: "[email protected]",
        defaultApiSender: "[email protected]",
      },
    },
  },
});

Usage

Sending an Email

To send an email, use the send function provided by the email provider. Here is an example:

// controllers/email.js

module.exports = {
  async sendEmail(ctx) {
    const { to, subject, text, html, attachments } = ctx.request.body;

    try {
      await strapi.plugins["email"].services.email.send({
        to,
        subject,
        text,
        html,
        attachments,
      });
      ctx.send({ message: "Email sent successfully" });
    } catch (err) {
      ctx.send({ error: "Failed to send email" });
    }
  },
};

Send Options

| Option | Type | Description | | ------------- | ----------------------------------------------------------------------- | ------------------------------------ | | to | string | Recipient email address | | subject | string | Subject of the email | | from | string (optional if defaultFrom is defined in provider settings) | Email address of the sender | | apiSender | string (optional if defaultApiSender is defined in provider settings) | API sender email address | | cc | string (optional) | CC email addresses, comma-separated | | bcc | string (optional) | BCC email addresses, comma-separated | | replyTo | string (optional) | Reply-to email address | | text | string (optional) | Text body of the email | | html | string (optional) | HTML body of the email | | attachments | array (optional) | Attachments to include in the email |

Contributing

Contributions are welcome! If you have any improvements or suggestions, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.