Quick setup examples

Auth0

Send Auth0 transactional emails — verification codes, password resets, and more — through MailBlastr.

Auth0 supports custom email providers, so you can route its transactional mail through MailBlastr. Authentication flows depend on reliable delivery for verification codes, password resets, and other crucial emails. Auth0 Actions run in a sandboxed Node.js runtime where npm packages cannot be installed, so the examples below call the MailBlastr REST API directly using the global fetch.

Prerequisites

Before you start, you will need:

Set up MailBlastr as the email provider

In the Auth0 Dashboard, go to Branding → Email Provider and toggle on Use my own email provider. Choose the SMTP provider and enter your MailBlastr SMTP credentials:

Hoststringoptional

smtp.mailblastr.com

Portnumberoptional

587 (STARTTLS) or 465 (SMTPS).

Usernamestringoptional

mailblastr

Passwordstringoptional

Your API key, e.g. mb_xxxxxxxxx.

Fromstringoptional

An address on your verified domain.

Click Save, then Send Test Email to confirm it works. The message appears in your MailBlastr dashboard and event log. See Send with SMTP for ports and security details.

Send emails with Auth0 Actions (optional)

For more control — per-organization sender addresses, conditional routing, or custom logic — use an Auth0 Action that calls the MailBlastr API directly with fetch. In the Auth0 Dashboard, go to Actions → Library and create a new Custom action.

Store your API key as a secret named MAILBLASTR_API_KEY on the Action. The Actions runtime provides a global fetch and does not support npm installs, so call the REST API directly. The following example sends a security alert on first login:

Post Login action
exports.onExecutePostLogin = async (event, api) => {
  if (event.stats.logins_count !== 1) return;

  await fetch('https://api.mailblastr.com/emails', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${event.secrets.MAILBLASTR_API_KEY}`,
    },
    body: JSON.stringify({
      from: 'Security <security@yourdomain.com>',
      to: event.user.email,
      subject: 'New login detected',
      html: `<p>Hi ${event.user.name}, a new login was detected from ${event.request.ip}.</p>`,
    }),
  });
};

Deploy it by adding the Action to the Post Login trigger under Actions → Triggers.

Use a MailBlastr template

Instead of inline html, you can reference a published template and pass variables. The example below uses a template with the id login-detected and two variables:

Post Login action (template)
exports.onExecutePostLogin = async (event, api) => {
  if (event.stats.logins_count !== 1) return;

  await fetch('https://api.mailblastr.com/emails', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${event.secrets.MAILBLASTR_API_KEY}`,
    },
    body: JSON.stringify({
      from: 'Security <security@yourdomain.com>',
      to: event.user.email,
      template: {
        id: 'login-detected',
        variables: {
          first_name: event.user.name,
          ip_address: event.request.ip,
        },
      },
    }),
  });
};

Debugging email delivery

When something goes wrong, check both sides of the chain:

  • Auth0 Logs (Monitoring → Logs) show send events and any errors raised by the email provider.
  • MailBlastr Logs show the delivery side: accepted, delivered, opened, bounced.
See the full request body — cc, bcc, reply_to, tags, and more — in the Send an email reference.