Brevo (formerly Sendinblue) is an all-in-one marketing & communication platform that helps businesses send:
- Emails (transactional + marketing)
- SMS / WhatsApp messages
- Automation campaigns
- CRM-based customer communication
π In simple words:
Itβs a tool to send emails and manage customers professionally, instead of relying on basic SMTP or Gmail. Sending an email using via Brevo API SMTP mails. Follow the steps and full working codes.
π Step 1: Get Your Brevo API Key
- Login to Brevo
- Go to: SMTP & API β API Keys
- Copy your v3 API key (Generate API key if not created)
β Step 2: Working PHP Code (Brevo API)
<?php
$fullName = 'a';
$email = 'b@gmail.com';
$service = 'c';
$message = 'd';
$phone = 'e';
if ($fullName == '' || $email == '' || $phone == '' || $service == '' || $message == '') {
echo json_encode(['success' => false, 'message' => 'Please fill all the details']);
exit;
}
$html = "<p>Dear Team <br />
You have received 1 email enquiry. <br /><br />
Name: $fullName <br />
Email: $email <br />
Phone: $phone <br />
Service: $service <br />
Message: $message <br /><br />
Kindly Contact the sender. <br />Thank you.</p>";
// β
Brevo API endpoint
$url = "https://api.brevo.com/v3/smtp/email";
// β
API payload
$data = [
"sender" => [
"name" => "Website Enquiry",
"email" => "youremail@gmail.com" // must be verified in Brevo
],
"to" => [
[
"email" => "receiver-email@gmail.com",
"name" => "Receiver Name"
]
],
"replyTo" => [
"email" => $email,
"name" => $fullName
],
"subject" => "New Enquiry Details - Website",
"htmlContent" => $html
];
// β
cURL request
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"api-key: YOUR_BREVO_API_KEY_HERE",
"content-type: application/json"
],
]);
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
// β
Response handling
if ($error) {
echo json_encode(['success' => false, 'message' => $error]);
} else {
$result = json_decode($response, true);
if (isset($result['messageId'])) {
echo json_encode(['success' => true, 'message' => 'Email sent successfully!']);
} else {
echo json_encode(['success' => false, 'message' => $response]);
}
}
Arnav Softech is also here to help you for your marketing automation and sending email work. We have good team to work on Website Design Services where you will get very good solution for your need.