Lovable
Lovable is a platform that lets you build apps and websites by chatting with AI. In this article, you’ll learn how to connect it to Mailtrap and add email-sending functionality to your projects.
Before we start:
Add and verify your email sending domain since Mailtrap allows you to send emails only from a verified domain.
Create a Supabase account and a project, and integrate it with Mailtrap. The process takes ~5 minutes and lets you safely store your Mailtrap credentials.
Step 1. Add your Mailtrap credentials
According to Lovable’s security best practices, you shouldn’t store secrets in frontend code since it’s visible to users and can be compromised. Instead, ask Lovable to securely add your Mailtrap credentials with a prompt like this one:
Add the Mailtrap email API token and Mailtrap From Email securely without exposing it in the frontend code
Lovable will then offer to enable Lovable Cloud, where you can securely store your credentials without worrying about ever exposing them. To continue, click Allow.

Next, add the following two secrets:
MAILTRAP_API_TOKEN– This is the Mailtrap API token, which you can create at any time from your account.MAILTRAP_FROM_EMAIL– This is the email address with the verified Mailtrap sending domain you’ve added after creating an account.

Finally, prompt Lovable to use Mailtrap email API to send emails from your project, just like so:
From now on, please use Mailtrap email API to send emails from my project
The AI will go through Mailtrap API documentation and create a backend function for sending emails via Mailtrap.
Step 2. Start sending emails
Once you connect your Lovable project to Mailtrap, you can start sending emails. If you followed everything thus far, you should receive the email in your inbox in a few seconds.
Here it is in a Gmail inbox I used as my to address:

And here it is in the Mailtrap Email Logs:

Next steps
Your Lovable application now has full email sending and contact management capabilities through Mailtrap integration. You can extend this setup by adding more sophisticated email templates, managing contacts, and creating automated email workflows.
Last updated
Was this helpful?

