Module: EmailFuse::Batch

Defined in:
lib/email_fuse/batch.rb

Overview

Module responsible for wrapping Batch email sending API

Class Method Summary collapse

Class Method Details

.send(params = [], options: {}) ⇒ Hash

Examples:

Send batch with strict validation (default)

EmailFuse::Batch.send([
  { from: "[email protected]", to: ["[email protected]"], subject: "Hello", html: "<p>Hi</p>" }
])

Send batch with permissive validation

response = EmailFuse::Batch.send(emails, options: { batch_validation: "permissive" })
# response[:data] contains successful email IDs
# response[:errors] contains validation errors with index and message

Parameters:

  • params (Array<Hash>) (defaults to: [])

    Array of email parameters (max 100 emails)

  • options (Hash) (defaults to: {})

    Additional options for the request

Options Hash (options:):

  • :idempotency_key (String)

    Optional idempotency key

  • :batch_validation (String)

    Batch validation mode: “strict” (default) or “permissive”

    • “strict”: Entire batch fails if any email is invalid

    • “permissive”: Sends valid emails and returns errors for invalid ones

Returns:

  • (Hash)

    Response with :data array and optional :errors array (in permissive mode)



29
30
31
32
33
# File 'lib/email_fuse/batch.rb', line 29

def send(params = [], options: {})
  path = "emails/batch"

  EmailFuse::Request.new(path, params, "post", options: options).perform
end