Gemini
This guide shows you how to send emails from a verified domain and manage contacts with custom fields and optional List IDs with Gemini 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 Gemini project environment
Ability to set environment variables in your Gemini hosting setup (via .env files or runtime configuration)
Ready-made prompts for Gemini integration
You can use the following prompts to instruct Gemini 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.
Gemini provides you with accurate, safe flows, and the code. However, it uses placeholders for credentials, and they need to be added in manually. And you need a proper IDE to test, run, and deploy your project.
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.
Create/update a contact in Mailtrap
At the moment a direct Contacts API is under development for the official Python SDK. You can use REST instead.
Troubleshooting Gemini-powered environments
Environment variables not loading – Gemini environments may require .env loading via
dotenvin Node.js orpython-dotenvin Python.Port access restrictions – Some Gemini hosting providers block SMTP - so use only HTTPS Email API as explained in this article.
Missing dependencies – Always run
npm installorpip installafter Gemini regenerates files to ensure all Mailtrap SDK dependencies are installed.CORS or cross-domain errors – If calling Mailtrap from a Gemini web client, route requests through your backend to keep API token secure.
Next steps
Use Mailtrap Templates to send branded Gemini-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?

