Socket
Book a DemoInstallSign in
Socket

@pubsweet/component-send-email

Package Overview
Dependencies
Maintainers
5
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pubsweet/component-send-email

send email configured for pubsweet

0.4.18
latest
npmnpm
Version published
Weekly downloads
209
151.81%
Maintainers
5
Weekly downloads
 
Created
Source

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)
  },
}

FAQs

Package last updated on 08 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.