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 🙏

© 2025 – Pkg Stats / Ryan Hefner

free-mail-sender

v2.0.0

Published

This Strapi plugin is designed to streamline the process of sending emails through the REST API. It enables you to send emails using different providers and customize the email content to suit your specific needs.

Downloads

44

Readme

Strapi plugin free-mail-sender

This Strapi plugin is designed to streamline the process of sending emails through the REST API. It enables you to send emails using different providers and customize the email content to suit your specific needs.


Installation

npm i free-mail-sender

Or

yarn add free-mail-sender

Or

pnpm i free-mail-sender

Config

To allow public use to the POST endpoint, go to:

<URL>/admin/settings/users-permissions/roles/2

Pick Free-mail-sender selector and check the mailto box option

Usage

Examples

Send an email:

Using a POST request to the following endpoint:

<URL>/api/free-mail-sender/send-email
  1. With the following body to a single recipient:
{
    "toEmail": "[email protected]",
    "subject": "Important subject",
    "mailText": "Simple text content"
}

Or

  1. With the following body (using html content) to a single recipient:
{
    "toEmail": "[email protected]",
    "subject": "Important subject",
    "mailText": "<p><b>HTML</b> content</p>"
}

Or

  1. To multiple recipients using an array with simple content in HTML:
{
  "toEmail": [
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ],
  "subject": "Important subject",
  "mailText": "<p><b>HTML</b> content</p>"
}

Or

  1. With complex content to multiple recipients:
{
  "toEmail": [
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ],
  "subject": "Important subject",
  "mailText": "<!DOCTYPE html><html><head><style>#myHeader {background-color: lightblue;color: black;padding: 40px;text-align: center;} </style></head><body><h2>The id Attribute</h2><p>Use CSS to style an element with the id myHeader:</p><h1 id='myHeader'>My Header</h1></body></html>"
}

IMPORTANT

The current plugin sends mails vía SMTP. (In the future, it will support other providers), so you need to configure the SMTP settings in your setting of your email provider (Gmail, Outlook, etc).

Limits

The usage of SMTP to send mails has a limit of 300 emails per day to 100 different recipients, but check the limits of your email provider.


Configuration

The default values can be customized via the plugin config. To do it, create or edit your plugins.js/plugins.ts file.

Example configuration

config/plugins.js

module.exports = ({ env }) => ({
  'free-mail-sender': {
    config: {
      provider: 'gmail', // Check the providers list -> DEFAULT: 'outlook'
      sender: env('EMAIL_SENDER', ''),
      pass: env('PASSWORD_SENDER', ''),
      token: env("TOKEN", ''), // Token generated from Strapi UI
    },
  },
});

Or

config/plugins.ts

export default ({ env }) => ({
  'free-mail-sender': {
    config: {
      provider: 'gmail', // Check the providers list -> DEFAULT: 'outlook'
      sender: env('EMAIL_SENDER', ''),
      pass: env('PASSWORD_SENDER', ''),
      token: env("TOKEN", ''), // Token generated from Strapi UI
    },
  },
});

The plugin configuration requires the email and password of the sender. You can set them in the .env file using the variables EMAIL_SENDER and PASSWORD_SENDER as follows:

.env

JWT_SECRET=...

#...
[email protected]
PASSWORD_SENDER=superSecretPasswordMailHere
TOKEN=GeneratedTokenViaStrapiUI

Configuration options extended

  1. provider - 'gmail' | 'outlook' | 'yahoo' | 'zoho' | 'sendgrid' | 'mailgun' | 'yandex' | 'protonmail' | 'icloud' | 'aol' | 'zohomail' | 'gmx' -> DEFAULT: 'outlook'

Providers list

  • Gmail: 'gmail'
  • Outlook: 'outlook'
  • Yahoo: 'yahoo'
  • Zoho: 'zoho'
  • Sendgrid: 'sendgrid'
  • Mailgun: 'mailgun'
  • Yandex: 'yandex'
  • Protonmail: 'protonmail'
  • icloud: 'icloud'
  • aol: 'aol'
  • Zohomail: 'zohomail'
  • gmx: 'gmx'

Quick Tutorial Step by Step

1. Configurar el entorno en el front-end

Before starting, make sure to save the token generated from the Strapi UI as an environment variable in your front-end application. This token will be used as the public key to encrypt the email data.

// Create a string with the required format for the plugin
const mail = { 
  mail: `{"toEmail": ["${EMAIL}"],"subject": "${SUBJECT}","mailText": "${MAIL_TEXT}"}`,
};

2. Encrypt the Email Data

To secure the email data, use the encryptData function. You'll need the public token generated from Strapi (public key) as the second parameter.

// Import the 'crypto' module
const crypto = require("crypto");

/**
 * Encrypts the data using a public key
 * @param {String} data - Data to encrypt
 * @param {String} publicKey - Public key for encryption
 * @returns {String} - Encrypted data in base64
 */
const encryptData = (data, publicKey) => {
  publicKey = `-----BEGIN PUBLIC KEY-----\n${publicKey}\n-----END PUBLIC KEY-----`;
  const buffer = Buffer.from(data, "utf8");
  const encryptedData = crypto.publicEncrypt(
    {
      key: publicKey,
      padding: crypto.constants.RSA_PKCS1_OAEP_PADDING,
      oaepHash: "sha256",
    },
    buffer
  );
  return encryptedData.toString("base64");
};

// Use the function to encrypt the email data
const publicKey = process.env.STRAPI_PUBLIC_KEY; // Your public token from Strapi
const encryptedMail = encryptData(mail.mail, publicKey);

console.log("Encrypted mail:", encryptedMail);

3. Send the Encrypted Email

Make a POST request to the plugin endpoint using the encrypted email. Here's an example using fetch:

const sendEncryptedMail = async (encryptedMail) => {
  const response = await fetch("http://<STRAPI_URL>/api/free-mail-sender/send-email", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      mail: encryptedMail, // Encrypted email data
    }),
  });

  if (response.ok) {
    console.log("Email sent successfully");
  } else {
    console.error("Error sending the email:", await response.json());
  }
};

// Call the function with the encrypted mail
sendEncryptedMail(encryptedMail);

Contributing

The current development is in progress, so feel free to contribute to the project.