GoAdmio

brevo

Set up Brevo (Sendinblue) email sending for your domains: add the DNS records in Cloudflare, authenticate the domains, and monitor Brevo credits

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

/go/brevo connects your hosted domains to Brevo, a transactional email service used as an SMTP relay. It:

Run without a domain, it processes every main domain on the server. Subdomains are skipped.

Before you start

Requirement Where it is read from
Brevo API key BrevoAPIKey in the Config table of /var/lib/sqlite/config.db
Cloudflare account ID and API token CloudflareAccountID and CloudflareAPIToken in the same table
The domain's DNS zone in that Cloudflare account Cloudflare
The server's IP in Brevo's authorised IPs https://app.brevo.com/security/authorised_ips
jq installed Used to read the Brevo and Cloudflare responses
mailx installed Used only by check

Quick start

# Set up one domain
/go/brevo example.com

# Set up every main domain on the server
/go/brevo

Syntax

/go/brevo [domain]
/go/brevo check
/go/brevo config
/go/brevo auth

If you run it without root, it re-runs itself with sudo.


Options

Form What it does
/go/brevo <domain> Sets up one domain. Any first argument that contains a dot is treated as a domain.
/go/brevo Sets up every main domain in /home.
/go/brevo check Checks the Brevo credit balance and disables the Brevo relay if it is not being used.
/go/brevo config Writes the Brevo API key to /usr/local/goadmio/include/config/brevo.php.
/go/brevo auth Asks Brevo to authenticate every main domain, without changing DNS.

[!WARNING] Any first argument that is not check, config, auth, or a name with a dot runs the full setup for all domains. A typo such as chek does not stop; it starts the all-domains run.


Output

The command prints progress for each step, and the raw Brevo API response for auth. It does not print a final summary. Each run also adds a line to /var/log/go/brevo.log.

Message Meaning
[] example.com Setup started for this domain.
Found _dmarc record with ID: <id> An existing DMARC record is being removed.
Successfully deleted _dmarc record The old DMARC record was removed.
Failed to delete _dmarc record Cloudflare refused the delete. The response follows.
No _dmarc record found for example.com There was no DMARC record to remove.
Brevo Working | Credits (<n>)... check: the credit balance changed, so Brevo is in use.
Message Sent | Brevo Working | Credits (<n>)... check: the test message used a credit.
Deactivate Brevo... check: the test message did not use a credit, so the Brevo relay was turned off.

The check, config, and auth forms always exit with status 1, including on success. Do not use their exit status to detect errors.


Examples

# Set up one domain
/go/brevo example.com
# Set up every main domain
/go/brevo
# Check credits and disable Brevo if it is not working
/go/brevo check
# Write the API key for the GoAdmio panel
/go/brevo config
# Authenticate all main domains again, for example after DNS has propagated
/go/brevo auth

Troubleshooting

Symptom Likely cause Fix
No DNS records are created and nothing is reported The domain's zone was not found in Cloudflare, so the Zone ID is empty. Check the Cloudflare account ID and token, and that the domain is in that account.
Records are created but Brevo shows the domain as not authenticated DNS has not propagated yet, or the verification record is missing. Wait a few minutes, then run /go/brevo auth.
The verification TXT record is missing on some domains See Known issues. Run /go/brevo <domain> for those domains one at a time.
Brevo API calls are refused The server's IP is not in Brevo's authorised IPs. Add it at https://app.brevo.com/security/authorised_ips.
A subdomain was not set up /go/brevo without a domain skips subdomains. Pass the subdomain explicitly: /go/brevo sub.example.com.
The Brevo relay was turned off after check The test message did not use a credit. Check the SMTP settings and the Brevo account, then enable the relay again.
check does nothing No Brevo API key is saved, or no mail account has sent mail today. Save the API key, and run it again later in the day.
Existing DMARC policy was replaced Setup always replaces the _dmarc record. Set your own policy again with dmarc.

Details

Domain setup

For each domain, the command does the following:

  1. Looks up the domain's Zone ID in Cloudflare.

  2. Deletes the existing _dmarc TXT record. This runs twice, to remove a duplicate.

  3. Adds two DKIM CNAME records (TTL 3600, not proxied):

    Name Points to
    brevo1._domainkey b1.<domain-with-dashes>.dkim.brevo.com
    brevo2._domainkey b2.<domain-with-dashes>.dkim.brevo.com

    In <domain-with-dashes>, dots are replaced by dashes (example.com becomes example-com).

  4. Adds a _dmarc TXT record: v=DMARC1; p=none; rua=mailto:rua@dmarc.brevo.com.

  5. Registers the domain with Brevo and reads its verification code.

  6. Adds the verification code as a TXT record on the domain (@).

  7. Asks Brevo to authenticate the domain. If Brevo answers that it cannot yet, waits 10 seconds and tries once more.

Record creation is silent. A record that already exists is not reported as an error.

Which domains are processed

Without a domain, the command goes through every directory in /home whose name contains a dot, and keeps the main domains. A domain with one dot (example.com) is a main domain. For longer names, the command removes known two-part endings such as .co.uk or .com.au and treats the name as a subdomain if a dot remains.

check

  1. Reads the stored credit value and the current credits from the Brevo account.
  2. If they differ, prints the new value and saves it. Brevo is working.
  3. If they are the same, picks the mail account that has sent the most mail today and sends a test message from it through the server's mail relay.
  4. Waits 3 seconds and reads the credits again.
  5. If the credits are still the same, sets Active=0 for every SMTP relay with brevo.com in its host in /var/lib/sqlite/smtp.db, then rebuilds the mail maps with vmail.
  6. Otherwise, saves the new credit value.

It is meant to be run on a schedule, for example from cron.

config

Writes a small PHP file that defines $BrevoAPIKey, and sets the file permission to 777. The panel reads the key from this file.

Known issues


See also

Command Description
dmarc Add a DMARC TXT record in Cloudflare (auto-generated or custom value)
dkim Add a DKIM TXT record in Cloudflare (auto-generated or custom value)
spf Add or refresh the SPF TXT record via Cloudflare
cloudflare Manage DNS records using Cloudflare's API
smtp Manage the SMTP port: block, unblock, and change it
vmail Rebuild the Postfix/Dovecot vmail maps
troubleshoot Troubleshoot email problems in GoAdmio