3.6.11 • Published 1 year ago

strapi-provider-email-nodemailer v3.6.11

Weekly downloads
1,332
License
SEE LICENSE IN LI...
Repository
github
Last release
1 year ago

strapi-provider-email-nodemailer


Deprecation Warning :warning:

Hello! We have some news to share,

We’ve decided it’ll soon be time to end the support for strapi-provider-email-nodemailer.

After years of iterations, Strapi is going to V4 and we won’t maintain V3 packages when it’ll reach its end-of-support milestone (~end of Q3 2022).

If you’ve been using strapi-provider-email-nodemailer and have migrated to V4 (or if you want to), you can find the equivalent and updated version of this package at this URL and with the following name on NPM: @strapi/provider-email-nodemailer.

If you’ve contributed to the development of this package, thank you again for that! We hope to see you on the V4 soon.

The Strapi team


Resources

Links

Prerequisites

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

Installation

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

# using npm
npm install strapi-provider-email-nodemailer --save

Example

Path - config/plugins.js

module.exports = ({ env }) => ({
  email: {
    provider: 'nodemailer',
    providerOptions: {
      host: env('SMTP_HOST', 'smtp.example.com'),
      port: env('SMTP_PORT', 587),
      auth: {
        user: env('SMTP_USERNAME'),
        pass: env('SMTP_PASSWORD'),
      },
      // ... any custom nodemailer options
    },
    settings: {
      defaultFrom: 'hello@example.com',
      defaultReplyTo: 'hello@example.com',
    },
  },
});

Check out the available options for nodemailer: https://nodemailer.com/about/

Development mode

You can override the default configurations for specific environments. E.g. for NODE_ENV=development in config/env/development/plugins.js:

module.exports = ({ env }) => ({
  email: {
    provider: 'nodemailer',
    providerOptions: {
      host: 'localhost',
      port: 1025,
      ignoreTLS: true,
    },
  },
});

The above setting is useful for local development with maildev.

Custom authentication mechanisms

It is also possible to use custom authentication methods. Here is an example for a NTLM authentication:

const nodemailerNTLMAuth = require('nodemailer-ntlm-auth');

module.exports = ({ env }) => ({
  email: {
    provider: 'nodemailer',
    providerOptions: {
      host: env('SMTP_HOST', 'smtp.example.com'),
      port: env('SMTP_PORT', 587),
      auth: {
        type: 'custom',
        method: 'NTLM',
        user: env('SMTP_USERNAME'),
        pass: env('SMTP_PASSWORD'),
      },
      customAuth: {
        NTLM: nodemailerNTLMAuth,
      },
    },
    settings: {
      defaultFrom: 'hello@example.com',
      defaultReplyTo: 'hello@example.com',
    },
  },
});

Usage

:warning: The Shipper Email (or defaultfrom) may also need to be changed in the Email Templates tab on the admin panel for emails to send properly

To send an email from anywhere inside Strapi:

await strapi.plugins['email'].services.email.send({
  to: 'someone@example.com',
  from: 'someone2@example.com',
  subject: 'Hello world',
  text: 'Hello world',
  html: `<h4>Hello world</h4>`,
});

The following fields are supported:

FieldDescription
fromEmail address of the sender
toComma separated list or an array of recipients
replyToEmail address to which replies are sent
ccComma separated list or an array of recipients
bccComma separated list or an array of recipients
subjectSubject of the email
textPlaintext version of the message
htmlHTML version of the message
attachmentsArray of objects See: https://nodemailer.com/message/attachments/

Troubleshooting

Check your firewall to ensure that requests are allowed. If it doesn't work with

port: 465,
secure: true

try using

port: 587,
secure: false

to test if it works correctly.

3.6.11

1 year ago

3.6.10

2 years ago

3.6.9

2 years ago

3.6.8

3 years ago

3.6.7

3 years ago

3.6.6

3 years ago

3.6.5

3 years ago

3.6.4

3 years ago

3.6.3

3 years ago

3.6.0-beta.3

3 years ago

3.6.0-beta.4

3 years ago

3.6.0-beta.5

3 years ago

3.6.2

3 years ago

3.6.1

3 years ago

3.6.0

3 years ago

3.6.0-beta.2

3 years ago

3.6.0-beta.1

3 years ago

3.6.0-next.0

3 years ago

3.6.0-beta.0

3 years ago

3.5.4

3 years ago

3.5.4-next.0

3 years ago

3.5.3

3 years ago

3.5.2

3 years ago

3.5.1

3 years ago

3.5.0

3 years ago

3.5.0-next.3

3 years ago

3.4.6

3 years ago

3.5.0-beta.0

3 years ago

3.5.0-next.1

3 years ago

3.5.0-next.2

3 years ago

3.4.5

3 years ago

3.4.4

3 years ago

3.4.3

3 years ago

3.4.2

3 years ago

3.5.0-next.0

3 years ago

3.4.1

3 years ago

3.4.0

3 years ago

3.4.0-beta.3

3 years ago

3.4.0-beta.2

3 years ago

3.4.0-beta.1

3 years ago

3.4.0-beta.0

3 years ago

3.3.5-next.0

3 years ago

3.3.4

3 years ago

3.3.5-next.1

3 years ago

3.3.3

3 years ago

3.3.2

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.0.0

4 years ago

2.0.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago