Nutritious Pancake Mountain
Have ideas to improve npm?Join in the discussion! »

strapi-provider-email-gmail-2loTypeScript icon, indicating that this package has built-in type declarations

3.1.5 • Public • Published

strapi-provider-email-gmail-2lo

This package is an email provider for the headless CMS Strapi. You can use this provider to send mail programmatically with strapi-plugin-email.

This provider enables you to send email with the Gmail API using a 2-legged OAuth configuration, for example when using G Suite.

Installation

# using yarn 
yarn add strapi-provider-email-gmail-2lo
 
# using npm 
npm install strapi-provider-email-gmail-2lo --save

Setup

  1. Enable the Gmail API
  2. Configure the OAuth consent screen
  3. Create a service account
  4. Create a new Private key for your service account
  5. Configure the provider in config/plugins
Variable Type Description Required Default
provider string The name of the provider you use yes
providerOptions object Provider options yes
providerOptions.username string An existing email address within your domain/project yes
providerOptions.clientId number Service account API Client id yes
providerOptions.privateKey string Service account private key yes
settings object Settings no {}
settings.defaultFrom string Default sender mail address, exist in domain no undefined
settings.defaultReplyTo string | array Default address or addresses the receiver is asked to reply to no undefined

Example

Path - config/plugins.js

module.exports = ({ env }) => ({
  // ...
  email: {
    provider: 'gmail-2lo',
    providerOptions: {
      username: 'myemail@example.com',
      clientId: env('EMAIL_CLIENT_ID'),
      privateKey: env('EMAIL_PRIVATE_KEY').replace(/\\n/g, '\n'),
    },
    settings: {
      defaultFrom: 'myemail@example.com',
      defaultReplyTo: 'myemail@example.com',
    },
  },
  // ...
});

TIP: When using environment variables for your privateKey, as in the example above, include all the \n in you .env file, like so:

EMAIL_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nAbC...xYz\n-----END PRIVATE KEY-----\n"

G Suite

When using G Suite follow these steps authorize the right scopes:

  1. Go to G Suite admin dashboard > Security > Advanced settings > Manage domain-wide delegation
  2. Add an authorized client
  3. Authorize

Resources

Links

Install

npm i strapi-provider-email-gmail-2lo

DownloadsWeekly Downloads

72

Version

3.1.5

License

MIT

Unpacked Size

8.56 kB

Total Files

8

Homepage

strapi.io/

Last publish

Collaborators

  • avatar