Skip to main content
Before continuing, make sure you’ve completed the SDK setup and requirements.

Overview

Sending bulk emails is a powerful feature that allows you to reach a large audience efficiently. This guide will walk you through the process of sending bulk emails using the Nuntly API.

Sending Bulk Emails

To send bulk emails, you can use the bulk.send method provided by the Nuntly SDK. This method allows you to send multiple emails in a single request.
const { data, error } = await nuntly.emails.bulk.send({
  emails: [
    {
      from: '[email protected]',
      subject: 'Welcome to Tomlinson AI!',
      to: '[email protected]',
      text: 'Thank you for signing up! Please verify your email address.',
    },
    {
      from: '[email protected]',
      subject: 'Welcome to Tomlinson AI!',
      to: '[email protected]',
      text: 'Thank you for signing up! Please verify your email address.',
    },
  ],
});

if (error) {
  return console.error('Error sending bulk emails:', error);
}
console.log(`Bulk emails sent successfully 🎉`, data);
In the example above, we are sending two emails in a single request. You can add as many email objects as needed to the emails array, up to the maximum limit (20) allowed by the Nuntly API. Each email object can contain the same properties as a single email, such as from, to, subject, html, and text. This allows you to customize each email individually.

Sending Bulk Emails with fallback

You can specify fallback properties if you want to have default values for certain fields across all emails. For example:
const { data, error } = await nuntly.emails.bulk.send({
  fallback: {
    from: '[email protected]',
    subject: 'Welcome to Tomlinson AI!',
  },
  emails: [{
    to: '[email protected]',
      text: 'Thank you for signing up! Please verify your email address Carlo.',

    }, {
      to: '[email protected]'
      text: 'Thank you for signing up! Please verify your email address Pinky.',}],
});
In this example, the from and subject fields are set in the fallback object, so they will be used for all emails unless overridden in the individual email objects. If there is an error with one of the emails in the bulk request, the entire request will fail, and no emails will be sent. Make sure to handle errors appropriately in your application. If the request is successful, the data object will contain information about the sent emails, including their unique bulk id and the status of each email.