Batch API requests

How to exceed recipient limits by sending emails in batches

MailSlurp enforces limits on the number of recipients that can be sent per email sending request. The email sending options permit maximum 10 to, cc or bcc recipients per field. This means if you wish to send to more than 10 recipients per field you should batch your API requests:

How to split requests

Batch your recipient requests by splitting an array of recipients into chunks:

// MailSlurp limit `to`, `bcc` and `cc` recipient fields to maximum 10 recipients
// so to send emails to more than 10 recipients batch your api requests
const chunkSize = 10;
for (let i = 0; i < recipients.length; i += chunkSize) {
    const recipientGroup: string[] = recipients.slice(i, i + chunkSize);
    // add a pause to avoid rate limits
    await new Promise(r => setTimeout(r, 100));
    // send email to chunk of recipients
    await mailslurp.inboxController.sendEmailAndConfirm({
        inboxId: inbox.id,
        sendEmailOptions: {
            to: recipientGroup,
            subject
        }
    })
}

Remember to include a time pause in your request loop to avoid rate limiting.