Strapi Microsoft Graph Email Provider logo

Strapi Microsoft Graph Email Provider

By Antoine de Chassey

Strapi custom email provider for Microsoft Graph

Latest version

v1.0.6

released November 3, 2025

npm install strapi-provider-email-microsoft-graph

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

OptionTypeDescription
tenantIdstringYour Azure AD tenant ID
clientIdstringYour application client ID
clientSecretstringYour application client secret

Settings

OptionTypeDescription
defaultFromstringDefault from email address
defaultReplyTostring | string[]Default replyTo email address(es)
defaultApiSenderstringDefault 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: "no-reply@example.com",
        defaultReplyTo: "support@example.com",
        defaultApiSender: "api@example.com",
      },
    },
  },
});

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

OptionTypeDescription
tostring | string[]Recipient email address(es)
subjectstringSubject of the email
fromstring (optional if defaultFrom is defined in provider settings)Email address of the sender
apiSenderstring (optional if defaultApiSender is defined in provider settings)API sender email address
ccstring (optional)CC email addresses, comma-separated
bccstring (optional)BCC email addresses, comma-separated
replyTostring | string[] (optional)Reply-to email address(es)
textstring (optional)Text body of the email
htmlstring (optional)HTML body of the email
attachmentsarray (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.


Submit your content

Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.

Submit
Submit your content