/bolt-ai-integration

Bolt.new AI and Mailgun integration: Step-by-Step Guide 2025

Learn how to integrate Bolt.new AI with Mailgun in 2026 with this simple step-by-step guide for seamless email automation and smarter workflows.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to integrate Bolt.new AI with Mailgun?

To integrate Bolt.new with Mailgun, you don’t “connect Bolt to Mailgun.” Instead, you write normal backend code (Node.js inside Bolt’s server files) that calls Mailgun’s REST API using your Mailgun API key and domain. You store secrets as environment variables in Bolt.new’s env panel. Then you expose a backend function or API route that your front‑end or AI agent can call to send actual emails. Bolt is just the workspace where you scaffold and run this integration.

 

How to integrate Bolt.new AI with Mailgun

 

The core idea is simple: Bolt.new runs your backend code, and that backend calls Mailgun’s REST API. You add your Mailgun API key + domain to environment variables, install the official Mailgun JS SDK (or use fetch), and create a backend endpoint that sends emails. This is the same way you’d integrate Mailgun anywhere else — Bolt just gives you a browser-based development environment.

 

  • You need: Mailgun account, an API key, and a sending domain.
  • You store secrets: MAILGUN_API_KEY and MAILGUN\_DOMAIN inside Bolt.new environment variables.
  • You write backend code to call Mailgun via SDK or direct HTTP.
  • Your front-end or AI agent triggers that backend endpoint.

 

Step-by-step inside Bolt.new (clear and correct)

 

1: Install Mailgun JS SDK in Bolt.new terminal:

npm install mailgun.js form-data

 

2: Add environment variables in Bolt.new’s Environment panel:

  • MAILGUN_API_KEY = your Mailgun private API key
  • MAILGUN\_DOMAIN = your verified Mailgun domain (example: mg.yourdomain.com)

These are required because you cannot safely hardcode secrets in code.

 

3: In your backend code (e.g., server.js or an API route), wire Mailgun

// server.js (Bolt backend)

// Import deps
import express from "express";
import Mailgun from "mailgun.js";
import FormData from "form-data";

const app = express();
app.use(express.json());

// Initialize Mailgun client
const mailgun = new Mailgun(FormData);
const mg = mailgun.client({
  username: "api",
  key: process.env.MAILGUN_API_KEY // pulled from Bolt env
});

// Example route to send an email
app.post("/send-email", async (req, res) => {
  try {
    const { to, subject, text } = req.body;

    const result = await mg.messages.create(process.env.MAILGUN_DOMAIN, {
      from: "Your App <[email protected]>", // must match Mailgun domain rules
      to,
      subject,
      text
    });

    res.json({ ok: true, result }); // success
  } catch (err) {
    res.status(500).json({ ok: false, error: err.message });
  }
});

export default app;

 

4: Call this route from your front-end or from an AI function inside Bolt

// Example: calling the backend from front-end
async function sendEmail() {
  const res = await fetch("/send-email", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      to: "[email protected]",
      subject: "Hello from Bolt + Mailgun",
      text: "This is a real email sent through Mailgun's API."
    })
  });

  const data = await res.json();
  console.log(data);
}

 

How Bolt.new AI fits into the workflow

 

Bolt’s AI doesn’t directly “integrate” with Mailgun. Instead, it can:

  • Generate the backend code like the example above.
  • Scaffold frontend forms that call your /send-email endpoint.
  • Run and test the integration inside its live preview.
  • Help debug real responses from Mailgun.

The real integration is always just API calls running from your Bolt backend.

 

Important constraints

 

  • Bolt cannot magically access your Mailgun account — you must provide API keys.
  • Use environment variables for all secrets. Never commit keys to code.
  • Your Mailgun domain must be verified or Mailgun will block outgoing mail.
  • Sandbox domains (Mailgun free tier) can only send to authorized recipients unless upgraded.

 

Production Hardening

 

  • Use Mailgun EU vs US endpoint depending on your account region.
  • Implement rate limiting on your send-email route.
  • Log Mailgun response IDs for debugging deliverability later.
  • li>Move secrets to your production environment (Railway, Vercel, Render, etc.).

 

This is the correct, real, and production-valid way to integrate Mailgun with a Bolt.new project. You are simply building a backend in Bolt that talks to Mailgun’s REST API securely via environment variables.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022