Skip to content

@apostrophecms/email

Extends: @apostrophecms/module ℹ️

This module manages general email functionality that Apostrophe modules use. The most significant feature is the nodemailer option, which is used to configure the Nodemailer third-party module.

Options

PropertyTypeDescription
fromStringThe default "from" address, either as the email address or with full name (e.g., '"Jane Doe" <jane@doe.com>').
nodemailerObjectAn options object for Nodemailer. Required for sending email unless the transport is directly set on self.transport. It is passed to nodemailer's createTransport method. See the Nodemailer documentation.

nodemailer

If using a pre-configured Nodemailer transport package that must be passed to the Nodemailer createTransport method (e.g., nodemailer-mailjet-transport, nodemailer-mailgun-transport), you may assign that package to the nodemailer option as well.

javascript
const mailjetTransport = require('nodemailer-mailjet-transport');

module.exports = {
  options: {
    from: '"Jane Doe" <jane.doe@my-website.com>',
    nodemailer: mailjetTransport({
      /// Mailjet configuration...
    })
  }
};
modules/@apostrophecms/email/index.js

If needed, you may assign the fully created transport directly to self.transport and omit the nodemailer option.

javascript
const nodemailer = require('nodemailer');
const mailjetTransport = require('nodemailer-mailjet-transport');

module.exports = {
  init(self) {
    self.transport = nodemailer.createTransport(mailjetTransport({
      // Mailjet configuration...
    }), {
      // A full set of message defaults...
    })
  }
};
modules/@apostrophecms/email/index.js