Sending Emails in Bulk

Notify provides powerful capabilities for sending emails to multiple recipients at once. This guide covers how to use the bulk sending features through both the dashboard interface and the API.

Notify's dashboard offers two main methods for bulk sending:

  1. Plain Text/HTML Emails: Send the same content to multiple recipients
  2. Template-Based Emails: Send personalized content to multiple recipients using templates and variables

Sending The Same Email Content to Multiple Recipients


Here, you can send the same email content (composed in plaintext or HTML) to multiple recipients. Follow these steps:

  1. Navigate to the Send Email section in your dashboard
  2. Enter your email subject and message (using plaintext, or bring your own HTML)
  3. Choose between two methods to add recipients:
    • Add Recipients Manually: Add individual email addresses one by one. Click Add Recipients multiple times to add as many recipients as needed.

    • Import Recipients (CSV): Upload a CSV file, or manually type/paste in a CSV list of email addresses

Adding Recipients Manually

With manual entry, you can:

  • Add recipients one at a time using the "Add Recipient" button
  • Enter each recipient's email address
  • Remove recipients as needed
  • Track how many recipients are ready to send

Adding Recipients via CSV

The CSV import method supports:

  • Uploading CSV or TXT files (drag-and-drop or file browser)
  • Pasting a list of email addresses
  • Simple format with "email" as the header followed by one email address per line
  • Validation of email addresses before sending

Here's an example of the expected CSV format:

email
user1@example.com
user2@example.com
user3@example.com

Sending Template-Based Emails to Multiple Recipients


Here, you'll find template-based bulk sending. This is more powerful as it allows you to personalize content for each recipient:

  1. Navigate to the Send Email From Template section in your dashboard
  2. Select one of your saved email templates. You'll see a preview of the selected template.
  3. Again, you can add recipients manually, or import a CSV file.
  4. If your template includes template variables (e.g., {first_name}), you'll see it in the UI. Be sure to add these personalization variables through manual entry or CSV import.

Remember, when sending to multiple recipients using a template:

  • Each recipient requires values for all template variables
  • The system validates that all required variables are provided

Adding Recipients and Variables Manually

With manual entry for templates:

  • Add recipients one at a time
  • Enter the email address and values for each required variable
  • Variables are shown in a form for each recipient

Adding Recipients and Variables via CSV

With CSV import for templates:

  • Upload a CSV file, or manually type/paste in a CSV list of email addresses
  • Include the required variables in the CSV file

For templates with variables, your CSV must:

  • Include "email" as the first column
  • Include additional columns for each template variable
  • Have header names that match your template variables exactly
  • Provide values for all variables for each recipient

Example CSV format for a template with "name" and "order_id" variables:

email,name,order_id
john@example.com,John Smith,ORD-1234
jane@example.com,Jane Doe,ORD-5678

Doing All Of That Programmatically


While the dashboard provides a user-friendly interface for bulk sending, you may need to send emails programmatically for more complex scenarios.

This approach simply involves calling the API endpoints (/api/public/v1/send-email and /api/public/v1/send-email-from-template) you've read about before, in a loop, to send emails to multiple recipients.

Here's a simple example:

async function sendBulkEmails(recipients, subject, message) {
  const results = {
    success: [],
    failed: []
  };
  
  // Loop through each recipient
  for (const recipient of recipients) {
    try {
      // Call the send-email API endpoint
      const response = await fetch('https://notify.cx/api/public/v1/send-email', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'x-api-key': 'YOUR_API_KEY'
        },
        body: JSON.stringify({
          subject,
          to: recipient.email,
          message
        })
      });
      
      const data = await response.json();
      
      if (data.success) {
        results.success.push(recipient.email);
      } else {
        results.failed.push({
          email: recipient.email,
          reason: data.message
        });
      }
      
      // Add a small delay between requests to avoid being rate limited
      await new Promise(resolve => setTimeout(resolve, 100));
    } catch (error) {
      results.failed.push({
        email: recipient.email,
        reason: error.message
      });
    }
  }
  
  return results;
}

And here's how to do it using the template-based API endpoint:

async function sendBulkTemplateEmails(recipients, templateId) {
  const results = {
    success: [],
    failed: []
  };
  
  for (const recipient of recipients) {
    try {
      // Call the send-email-from-template API endpoint
      const response = await fetch('https://notify.cx/api/public/v1/send-email-from-template', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'x-api-key': 'YOUR_API_KEY'
        },
        body: JSON.stringify({
          templateId,
          to: recipient.email,
          variables: recipient.variables // Object containing template variable mappings for this user
        })
      });
      
      const data = await response.json();
      
      if (data.success) {
        results.success.push(recipient.email);
      } else {
        results.failed.push({
          email: recipient.email,
          reason: data.message
        });
      }
      
      // Add a small delay between requests to avoid being rate limited
      await new Promise(resolve => setTimeout(resolve, 100));
    } catch (error) {
      results.failed.push({
        email: recipient.email,
        reason: error.message
      });
    }
  }
  
  return results;
}

For more, see our API reference: