Quick setup examples

Railway

Deploy an app to Railway that sends your first email using the mailblastr SDK.

Railway lets you focus on building your product instead of managing infrastructure, scaling automatically as you grow. Use the mailblastr Node SDK — it works the same on Railway as in any Node.js host. Install it with npm install mailblastr.

Prerequisites

Before you start, you will need:

1. Install the SDK

npm install mailblastr

2. Create a Railway project

Create a new project on Railway and deploy a Node.js service (for example, from a GitHub repo or with railway init from the Railway CLI).

3. Add your API key

In your service's Variables tab, add MAILBLASTR_API_KEY with your key. Railway injects it into the runtime environment so you never commit the secret.

Service variable
MAILBLASTR_API_KEY=mb_xxxxxxxxx

4. Send your first email

In a request handler (here, a minimal Node.js HTTP server), instantiate the SDK client and call mb.emails.send().

index.mjs
import { createServer } from 'node:http';
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr(process.env.MAILBLASTR_API_KEY);

createServer(async (_req, res) => {
  const { data, error } = await mb.emails.send({
    from: 'Acme <onboarding@yourdomain.com>',
    to: ['delivered@example.com'],
    subject: 'hello world',
    html: '<strong>it works!</strong>',
  });

  res.writeHead(error ? 500 : 200, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify(error ? { error } : { data }));
}).listen(process.env.PORT || 3000);

5. Deploy and verify

Once your deployment finishes, open the deploy URL to send your first email.

This basic example sends an email each time someone visits the deploy URL, so share the link with discretion.
See the full set of body fields in the Send an email reference.