0.4.18 • Published 3 years ago

@pubsweet/component-send-email v0.4.18

Weekly downloads
538
License
MIT
Repository
gitlab
Last release
3 years ago

Send Email

Configuration

In order to configure this component, simply add the path to your mailer configuration in your app's config file. For example:

  mailer: {
    path: `${__dirname}/mailer`,
  },

In this case, mailer.js creates a new AWS.SES object which will be used to send emails:

const AWS = require('aws-sdk')
const config = require('config')

module.exports = {
  transport: {
    SES: new AWS.SES({
      accessKeyId: config.SES.accessKey,
      secretAccessKey: config.SES.secretKey,
      region: config.SES.region,
    }),
  },
}

If you plan on using environment variables for your AWS account, you need to create a config/custom-environment-variables.json file with the following content:

{
  "SES": {
    "accessKey": "AWS_SES_ACCESS_KEY",
    "secretKey": "AWS_SES_SECRET_KEY",
    "region": "AWS_SES_REGION"
  }
}

Usage

The send-email component contains a send() function which takes a single mailData object which needs to contain at least the following properties: from, to, cc, bcc, subject, text, html.
It returns the resulting information provided by nodemailer. In most cases, you can just ignore it.

const Email = require('@pubsweet/component-send-email')
const config = require('config')

module.exports = {
  setupEmail: async toEmail => {
    const mailData = {
      from: config.get('mailer.from'),
      to: toEmail,
      cc: ccEmail,
      bcc: bccEmail,
      subject: 'You have been invited!',
      text: 'This is an email',
      html: '<p>This is an email</p>',
    }
    return Email.send(mailData)
  },
}
0.4.17

3 years ago

0.4.18

3 years ago

0.4.16

3 years ago

0.4.15

3 years ago

0.4.14

3 years ago

0.4.13

3 years ago

0.4.12

3 years ago

0.4.11

3 years ago

0.4.10

3 years ago

0.4.9

3 years ago

0.4.8

3 years ago

0.4.7

3 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

5 years ago

0.2.30

5 years ago

0.2.29

5 years ago

0.2.28

5 years ago

0.2.27

5 years ago

0.2.26

5 years ago

0.2.25

5 years ago

0.2.24

5 years ago

0.2.23

5 years ago

0.2.22

5 years ago

0.2.21

5 years ago

0.2.20

5 years ago

0.2.19

5 years ago

0.2.18

5 years ago

0.2.17

5 years ago

0.2.16

5 years ago

0.2.15

5 years ago

0.2.14

5 years ago

0.2.13

5 years ago

0.2.12

5 years ago

0.2.11

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago