pjs.sendEmail()

pjs.sendEmail()

To use this, you'll need to install the nodemailer NPM package into your Profound.js instance directory. For more information on this NPM package, see the following page: https://www.npmjs.com/package/nodemailer

Potentially breaking changes:

As of PJS 7.32.0, the version of nodemailer PJS depends on goes from 7x to 8x, introducing some changes. Profound.js itself is unaffected, but custom application code may be affected if it uses specific error properties:

  • err.code === 'NoAuth' (SMTP authentication credentials not provided when the server supports auth and forceAuth is enabled) is now err.code === 'ENOAUTH'

  • err.code === 'LegacyConfig' (deprecated configuration) is now err.code === 'ECONFIG'

  • err.type === 'FETCH' (HTTP fetch failure when loading remote message content such as a URL-referenced attachment) is now err.code === 'EFETCH'. Note that both the property name (typecode) and the value changed--existing checks against err.type will silently stop matching

 

 

 

This API sends an email. The NodeMailer SMTP transport details must be specified under the mailTransport configuration property, which can be stored in your Profound.js config.js file or your workspace .noderun/settings.json file.

Parameter

  • Email data object containing the following properties:

    • from - The email address of the sender. All email addresses can be plain ‘sender@server.com’ or formatted '“Sender Name” sender@server.com’.

    • to - Comma separated list or an array of recipient email addresses that will appear on the To: field

    • cc - Comma separated list or an array of recipient email addresses that will appear on the Cc: field

    • bcc - Comma separated list or an array of recipient email addresses that will appear on the Bcc: field

    • subject - The subject of the email

    • text - The plaintext version of the message as an Unicode string, Buffer, Stream or an attachment-like object ({path: ‘/var/data/…'})

    • html - The HTML version of the message as an Unicode string, Buffer, Stream or an attachment-like object ({path: ‘http://…'})

    • attachments - An array of attachment objects. Attachments can be used for embedding images as well.

      For additional properties and other details, refer to the nodemailer npm package documentation.

 

Return value

  • Information object providing the result from the transport. It may include various properties, such as the messageId. The exact format depends on the transport mechanism used.

 

Example
pjs.sendEmail({ from: 'Nodemailer <example@nodemailer.com>', to: 'Nodemailer <example@nodemailer.com>', subject: 'Test Email Message', text: 'For clients with plaintext support only', html: `<h1>Thank you for placing your order.</h1> Your order number is ${ordNum}.` });