MailSlurp logo

examples

How to send emails using queue backed architecture

Send queued email with MailSlurp so transactional messages can retry cleanly and still be tested against real inbox receipt.

MailSlurp supports sending emails with queue-backed methods for reliable transactional workflows. Queueing helps your app accept work quickly, retry delivery cleanly, and keep customer-facing email separate from short-lived network or provider delays.

What is a queue?

A message queue stores work until the next process is ready to handle it. For email, that means your application can enqueue a password reset, OTP code, receipt, invoice, or notification while the sending path manages pacing and retries.

In email delivery, queueing protects reliability in three ways:

  • it decouples user actions from slow SMTP or API handoffs,
  • it allows retry behavior for temporary delivery delays,
  • it makes message state easier to observe, alert on, and test.

For the broader delivery-state explanation, see queued meaning in email and SMTP queue meaning.

Example usage

Send with queue methods are available in all SDK libraries and the REST API. Here is an example using the MailSlurp Javascript client:

await mailslurp.inboxController.sendEmailWithQueue({
  inboxId: inboxId,
  sendEmailOptions: {
    to: [recipient],
    subject: "Sent with a queue",
    body:
      "Use queues to allow recovery of failed email " +
      "sending when account reaches limits or has payment issues",
  },
  // validate before adding to queue to fail early
  validateBeforeEnqueue: false,
});

When queued sending helps

Queued email is useful when a message matters enough to retry and measure:

  • account signup and email verification,
  • password resets and magic links,
  • OTP and MFA codes,
  • billing receipts and invoices,
  • operational notifications,
  • campaign QA and staged delivery checks.

Use MailSlurp inboxes to validate the outcome after the queued send. A strong test creates a fresh inbox, sends through the same queued path as production, waits for the latest email with a strict timeout, and asserts the subject, body, links, sender, recipient, attachments, and headers.

Queue recovery and testing

Queue-backed sending should still have a customer-facing delivery target. If a password reset has to arrive in 30 seconds, the release test should fail when the message stays queued longer than that.

Pair queued sending with:

With MailSlurp, queued sending and inbox receipt testing work together: your app gets resilient delivery behavior, and your team gets proof that the message reached a real inbox correctly and on time.