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
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
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.

To complete the project, Replit asks you to provide Mailtrap API token and the FROM_ADDRESS. Make sure to add and verify a domain first.
Contacts management only
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.

To complete the project, Replit asks you to provide MAILTRAP_ACCOUNT_ID token and the MAILTRAP_LIST_ID.
Step-by-step setup
Troubleshooting
FROM_ADDRESS rejected - Use a verified domain.
401/403 errors - Ensure API token is admin-level.
Next steps
Add Mailtrap Templates for branded messages.
Implement Contacts Management to store new subscribers in Mailtrap.
Last updated
Was this helpful?

