Mails
Send Emails

How to send emails

There are a few steps to send emails using ROQ BaaS SDK. First, you need to configure an email provider. Then, you need to create an email template. Finally, you can send emails via API.

Configure email provider

Make sure that an email provider is connected and activated. You will find a list of all integrations in the ROQ Console (opens in a new tab). To set up the email integration, please read this documentation section.

Create email template

Before sending emails, make sure to create email templates on ROQ Console. Read this documentation to create email template.

Send emails via API

Emails are sent using the sendMail API. You need to use the same key which you set to the email type. For instance to send a New Product News email with the unique key new-product-news and have data variables: recipients_name, website_url, your_name, your_position, and your_contact_information, you can send the email by using Node.js SDK

import { Platform } from '@roq/nodejs'
 
const client = new Platform({
	apiKey: process.env.ROQ_API_KEY,
	environmentId: process.env.ROQ_ENVIRONMENT_ID,
	host: process.env.ROQ_PLATFORM_URL
})
 
await client.asSuperAdmin().sendMail({
  mail: {
      key: "new-product-news",
      locale: "en-US",
      emails: ["test@randomemail.com"],
      data: [   
      {
        key: "recipients_name",
        value: "exampleValue"
      }, 
      {
        key: "website_url",
        value: "exampleValue"
      }, 
      {
        key: "your_name",
        value: "exampleValue"
      }, 
      {
        key: "your_position",
        value: "exampleValue"
      }, 
      {
        key: "your_contact_information",
        value: "exampleValue"
      }, 
    ]
  },
});