Replit

In this guide, you'll set up production email sending in a Replit project using the Mailtrap Email API with official SDKs (Node.js or Python), and learn how to create or update contacts in Mailtrap directly from your app.

You'll:

  • Send emails from your verified domain via the Mailtrap Email API

  • Store contacts for campaigns and automations, with optional custom fields and list membership

This tutorial uses the Replit Agent product.

Prerequisites

  • Verified sending domain in Mailtrap (required for production) — Setup guide

  • Admin API token with access to your verified domain and Contacts

  • Account ID (needed for Contacts) — find it here

  • Custom fields created in Mailtrap if you want to store extra structured data — create here

  • (Optional) List ID if you want to assign contacts to a list

  • Replit account and project (Node.js or Python)

Ready-made prompts (for Replit Agent)

Sending only

Prompt

Create a Node.js app that uses the Mailtrap SDK to send a production email via the Email API using a verified domain. Store the API token and from address in environment variables.

Replit Agent generating email sending code from prompt
Replit Agent sending prompt result

Contacts management only

Prompt

Write a Node.js script that uses the Mailtrap SDK to create or update a contact in Mailtrap. Include email, name, and custom fields. Store Account ID, API token, and optional List ID in environment variables.

Replit Agent generating contacts management code from prompt
Replit Agent contacts prompt result

Step-by-step setup

1

Set up Mailtrap

  1. Verify your sending domain in Mailtrap.

  2. Create an admin API token and keep it secure.

  3. Note your FROM_ADDRESS (must use the verified domain).

2

Create/open your Replit project

With Replit Agent - Use one of the prompts above. Replit does it all, you just need to add the credentials.

Manual setup:

Install SDKs:

Add secrets in Replit (use the Secrets panel):

3

Send a production email

4

Run and verify

  1. Click Run in Replit. (Note: Most of the time, the AI IDE does it for you.)

  2. Check the recipient's inbox.

Troubleshooting

  • FROM_ADDRESS rejected - Use a verified domain.

  • 401/403 errors - Ensure API token is admin-level.

Next steps

Last updated

Was this helpful?