Socket
Socket
Sign inDemoInstall

@pubsweet/component-send-email

Package Overview
Dependencies
10
Maintainers
5
Versions
57
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @pubsweet/component-send-email

send email configured for pubsweet


Version published
Weekly downloads
98
increased by4.26%
Maintainers
5
Install size
483 kB
Created
Weekly downloads
 

Readme

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

Last updated on 08 Jun 2021

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc