Discover how to integrate Lovable with Sendinblue effortlessly. Follow our step-by-step guide to boost your email marketing and automation.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
This step instructs you to create a new TypeScript file where you will write the code integrating the Sendinblue API with your Lovable project.
If your project has a folder for service files (for example, a folder named "services"), create a new file inside it called sendinblue.ts. If there is no such folder, you can create the file in the root directory of your project.
Paste the following code into the file sendinblue.ts. This code creates a SendinblueService class that will be responsible for sending emails via Sendinblue. It uses the built‐in fetch function so there is no need to install additional libraries.
export class SendinblueService {
private apiKey: string;
private apiUrl: string = 'https://api.sendinblue.com/v3';
constructor(apiKey: string) {
this.apiKey = apiKey;
}
async sendEmail(to: string, subject: string, content: string): Promise {
const payload = {
sender: { email: "yourverifiedsender@example.com" }, // Replace with your Sendinblue verified sender email
to: [{ email: to }],
subject: subject,
htmlContent: content,
};
const response = await fetch(${this.apiUrl}/smtp/email, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': this.apiKey,
},
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(Sendinblue API error: ${response.statusText});
}
return response.json();
}
}
Remember to replace [email protected] with the sender email you have verified in your Sendinblue account.
Now you need to integrate the Sendinblue service into your project code where you want to send emails. For example, if your Lovable project has a contact form and a corresponding TypeScript file (e.g., index.ts or a dedicated form handler file), add the following code.
If there is no terminal available in Lovable, simply copy the following code snippet into your existing TypeScript file where you handle form submissions.
import { SendinblueService } from './sendinblue';
// Instantiate the SendinblueService with your API key.
// Replace 'YOURSENDINBLUEAPI_KEY' with the actual API key provided in your Sendinblue account.
const sendinblueService = new SendinblueService('YOURSENDINBLUEAPI_KEY');
// Example function: Handles the form submission to send an email.
async function handleFormSubmit(event: Event) {
event.preventDefault();
// Assuming you have input fields with the IDs 'email', 'subject', and 'message' in your HTML form.
const emailField = document.getElementById('email') as HTMLInputElement;
const subjectField = document.getElementById('subject') as HTMLInputElement;
const contentField = document.getElementById('message') as HTMLInputElement;
try {
const result = await sendinblueService.sendEmail(
emailField.value,
subjectField.value,
contentField.value
);
console.log('Email sent successfully:', result);
// Optionally, show a success message to the user.
} catch (error) {
console.error('Error sending email:', error);
// Optionally, display an error message to the user.
}
}
// Attach the form submit event listener.
// Ensure that your HTML form has the ID 'contactForm'.
const form = document.getElementById('contactForm');
if (form) {
form.addEventListener('submit', handleFormSubmit);
}
This snippet imports the previously created Sendinblue service, instantiates it with your API key, and attaches a submit event listener to your form. Adjust the element IDs (email, subject, message, and contactForm) to match your actual HTML.
Instead of using a terminal to install dependencies, you should store your Sendinblue API key directly in the code. In the snippet from Step 2, replace 'YOURSENDINBLUEAPI_KEY' with the API key you received in your Sendinblue account.
For added security, if your no-code tool supports environment variables or secret management, look for a way to store your API key securely rather than hardcoding it. If not, ensure your project is protected and the key is not shared in public repositories.
After adding the files and updating the necessary placeholders, test your Sendinblue integration:
- Open the page containing your contact form in Lovable.
- Fill in the form fields and submit the form.
- Monitor the console (using the inbuilt debugging tools of Lovable if available) to check if the email sending process logs "Email sent successfully" or displays any error messages.
If an error occurs, re-check your API key, the sender email, and the HTML element IDs referenced in the code snippets.
This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.