Lovable

Lovablearrow-up-right 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:

Step 1. Add your Mailtrap credentials

According to Lovable’s security best practicesarrow-up-right, 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 Cloudarrow-up-right, 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 tokenarrow-up-right, 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 documentationarrow-up-right 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 Logsarrow-up-right:

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 templatesarrow-up-right, managing contactsarrow-up-right, and creating automated email workflowsarrow-up-right.

Last updated

Was this helpful?