Send email from PHP, three ways
Send from PHP with the Brevo PHP SDK on PHP 8.1 or later, PHPMailer with the Brevo SMTP relay, or cURL.

How it works
composer require getbrevo/brevo-php
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Brevo\Brevo;
use Brevo\TransactionalEmails\Requests\SendTransacEmailRequest;
use Brevo\TransactionalEmails\Types\SendTransacEmailRequestSender;
use Brevo\TransactionalEmails\Types\SendTransacEmailRequestToItem;
$client = new Brevo(apiKey: 'your-api-key');
$result = $client->transactionalEmails->sendTransacEmail(
new SendTransacEmailRequest([
'subject' => 'Hello from Brevo!',
'htmlContent' => '<html><body><p>Hello,</p><p>This is my first transactional email.</p></body></html>',
'sender' => new SendTransacEmailRequestSender([
'name' => 'Alex from Brevo',
'email' => '[email protected]',
]),
'to' => [
new SendTransacEmailRequestToItem([
'email' => '[email protected]',
'name' => 'John Doe',
]),
],
])
);
echo 'Email sent. Message ID: ' . $result->messageId . PHP_EOL;
$client = new Brevo(apiKey: $_ENV['BREVO_API_KEY'] ?? getenv('BREVO_API_KEY'));
use Brevo\Exceptions\BrevoApiException;
use Brevo\Exceptions\BrevoException;
try {
$client->transactionalEmails->sendTransacEmail($request);
} catch (BrevoApiException $e) {
$statusCode = $e->getCode();
$body = $e->getBody();
if ($statusCode === 401) {
echo 'Invalid API key';
} elseif ($statusCode === 429) {
echo 'Rate limited. Check Retry-After header.';
} else {
echo "API error {$statusCode}: " . $e->getMessage();
}
} catch (BrevoException $e) {
echo 'SDK error: ' . $e->getMessage();
}
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'smtp-relay.brevo.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'YOUR_SMTP_KEY';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
$mail->setFrom('[email protected]', 'My App');
$mail->addAddress('[email protected]', 'John Doe');
$mail->addReplyTo('[email protected]', 'Support');
$mail->Subject = 'Your order is confirmed';
$mail->Body = 'Hello John, your order #12345 has been received.';
$mail->send();
echo 'Email sent successfully';
} catch (Exception $e) {
echo "Error: {$mail->ErrorInfo}";
}
<?php
$apiKey = $_ENV['BREVO_API_KEY'];
$payload = json_encode([
'sender' => ['email' => '[email protected]', 'name' => 'My App'],
'to' => [['email' => '[email protected]', 'name' => 'User']],
'subject' => 'Welcome to My App!',
'htmlContent' => '<html><body><h1>Welcome!</h1><p>Thanks for signing up.</p></body></html>',
]);
$ch = curl_init('https://api.brevo.com/v3/smtp/email');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'api-key: ' . $apiKey,
'Content-Type: application/json',
],
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 201) {
$data = json_decode($response, true);
echo 'Sent! Message ID: ' . $data['messageId'];
} elseif ($httpCode === 429) {
echo 'Rate limit exceeded. Try again shortly.';
} else {
echo "Error {$httpCode}: {$response}";
}
Replace the API key, sender and recipient with your own. Read the key from an environment variable.
Ask your AI agent
Prompts for the Brevo MCP server.
Before I send email from my PHP app, check that I have a verified sender and an authenticated sending domain. List what is missing.
Read-only: it reads your Brevo account through the Brevo MCP server and changes nothing.
Setup in three steps
Get the right credential
Authenticate your sending domain and sender first. The SDK and cURL use an API key, created under SMTP & API, then API keys & MCP. PHPMailer uses an SMTP key from the SMTP tab, never an API key.
Pick a method and send
PHP 8.1 or later: install getbrevo/brevo-php with Composer, create a client with your API key and call transactionalEmails->sendTransacEmail. WordPress, shared hosting or PHP 7.x: PHPMailer with the SMTP relay. No Composer: cURL against /v3/smtp/email.
Handle errors and check the log
The SDK throws BrevoApiException for any non-2xx response. Confirm delivery under Transactional, then Email logs. For batches, use messageVersions on POST /v3/smtp/email. The SMTP relay does not support batch sending.


