Skip to content

About

Zero-config Mailtrap Inbound provisioning — folder→inbox→messages via one command. Forkable Claude skill + npx CLI. Only needs MAILTRAP_API_TOKEN.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mailtrap-inbound-setup

A Mailtrap Inbound inbox in one command. You bring the token; it brings everything else.

Setting up Mailtrap Inbound over the API is a four-step ritual: create a folder, create an inbox, copy the generated address, then wire up message polling. Every guide walks you through the same cURL sequence. This tool runs it for you. The only thing you provide is MAILTRAP_API_TOKEN.

It ships two ways: fork the Claude Code skill (SKILL.md at the root) or run it with npx. Zero dependencies, Node 18+.

Quickstart

export MAILTRAP_API_TOKEN=xxxxx      # account-level token (Settings > API Tokens)
npx github:VeljkoRailsware/mailtrap-inbound-setup setup
✔ Provisioned. Send test mail to: inbound-bench-8798df5e@inbound-mailtrap.io

Add these to your .env:
  MAILTRAP_INBOX_ID=710
  MAILTRAP_INBOUND_ADDRESS=inbound-bench-8798df5e@inbound-mailtrap.io

That's a live inbox. Send it an email, run list, watch it arrive.

What it does

setup provisions the inbound folder and inbox, prints the address and env vars, and with --write-env appends them to a .env. It's idempotent: ids are cached in .mailtrap-inbound.json, so re-runs reuse the same inbox instead of breeding new ones.

sandbox provisions an Email Sandbox inbox for spam and quality testing.

Inbound Email and Email Sandbox are separate Mailtrap products. Inbound Email receives and parses production mail. Email Sandbox tests it, and that's where SpamAssassin scoring lives. The inbound parse payload carries no spam score. The sandbox does. That's why spamcheck routes through the sandbox.

spamcheck is the payoff. Pipe it a message; it scores through Email Sandbox's SpamAssassin and prints the verdict:

echo "$BODY" | mailtrap-inbound spamcheck
# 🚩 SPAM  score 1000.9 / threshold 5
#   top rules: GTUBE (1000), DKIM_ADSP_NXDOMAIN (0.8)

It exits 1 when a message is flagged, so it drops into a pipeline as a gate. And it runs out-of-band against a sandbox copy, so it never sits in the path of real inbound traffic.

Full command list: setup · sandbox · spamcheck · list · get <id> · delete <id>. Run help for flags.

The one gotcha: use an account-level token

Inbound create needs an account-level API token. A token scoped to a single sending domain can read inbound but returns 403 Access forbidden on create. If you hit it, the tool says exactly that and points you to Settings > API Tokens.

Wiring it into your stack

mailtrap-inbound setup --write-env ./.env

Appends MAILTRAP_INBOX_ID and the inbound address to your env file. With the token you already exported, your inbound consumer is ready to poll.

Security

Your token lives in the environment, never the repo. .env and the .mailtrap-inbound.json state file are git-ignored. spamcheck sends to a sandbox that traps mail instead of delivering it.

Endpoints

Every command is these calls, so you can audit exactly what runs:

POST   /api/inbound/folders                      { name }   -> { id, name }
POST   /api/inbound/folders/{folder_id}/inboxes  { name }   -> { id, name, address }
GET    /api/inbound/inboxes/{inbox_id}/messages
POST   https://sandbox.api.mailtrap.io/api/send/{inbox_id}
GET    /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{id}/spam_report

Base: https://mailtrap.io/api · Auth: Authorization: Bearer <account-level token>

Local dev

git clone https://github.com/VeljkoRailsware/mailtrap-inbound-setup
node bin/cli.js help

No build step. One file, no dependencies, which is the whole point.

About

Zero-config Mailtrap Inbound provisioning — folder→inbox→messages via one command. Forkable Claude skill + npx CLI. Only needs MAILTRAP_API_TOKEN.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages