ChatGPT
This guide shows you how to send emails from a verified domain and manage contacts with custom fields and optional List IDs with ChatGPT and Mailtrap Email API.
Prerequisites
Before you start, make sure you have:
Verified sending domain in Mailtrap
Admin API token with access to your domain, Contacts, and Production Email API
Account ID (Go to Settings, then Account Settings in Mailtrap dashboard)
Optional List IDs if you want to store contacts in specific lists
Custom fields created in Mailtrap if you want to store extra metadata
Node.js or Python installed in your GPT project environment
Ability to set environment variables in your GPT hosting setup (via .env files or runtime configuration)
Ready-made prompts for GPT integration
You can use the following prompts to instruct GPT to integrate the service for you.
Email sending
Create a Node.js app that uses the Mailtrap SDK to send an email via the Email API from a verified domain. Store credentials in environment variables.
Email sending + HTML template
Generate a Python script using the Mailtrap SDK that sends a production email with HTML content and template variables.
Full integration
Build a Node.js app that sends a production email, then creates or updates a contact in Mailtrap Contacts with custom fields and optional List ID.
Use the Connectors feature under GPT Settings to link your GitHub repositories to GPT. This helps speed up the processes and may improve code quality.
Step-by-step setup guide
Prepare Mailtrap
Verify your sending domain in Mailtrap.
Create an Admin API token with
production_sendandcontacts_writescopes.Locate your Account ID in Settings > Account Settings.
(Optional) Create Lists if you plan to organize contacts.
(Optional) Create Custom Fields for storing metadata like
planorsignup_source.
Troubleshooting GPT-powered environments
Environment variables not loading – GPT environments may require .env loading via
dotenvin Node.js orpython-dotenvin Python.Port access restrictions – Some GPT hosting providers block SMTP - so use only HTTPS Email API as explained in this article.
Missing dependencies – Always run
npm installorpip installafter GPT regenerates files to ensure all Mailtrap SDK dependencies are installed.CORS or cross-domain errors – If calling Mailtrap from a GPT web client, route requests through your backend to keep API token secure.
Next steps
Use Mailtrap Templates to send branded GPT-generated emails with variables.
Add automation triggers in Mailtrap to send follow-ups to new contacts.
Track open and click rates with Mailtrap Email Tracking.
Last updated
Was this helpful?

