Brevo API Client
| (require brevo) | package: brevo |
1 Introduction
This library lets you send emails with Brevo from Racket. To use it, you’ll need to have a valid API key.
Brevo was formerly called Sendinblue, and this package was formerly called sendinblue. That package still exists as a deprecated wrapper that re-exports this one under the old names, so existing code keeps working.
2 Usage
Create a client with your API key, then send an email:
(require brevo) (define client (brevo (getenv "BREVO_API_KEY"))) (brevo-send-email client #:sender "Jane Doe <jane@example.com>" #:to (list "john@example.com") #:subject "Hello" #:text-content "Hi John!")
On success, this returns Brevo’s response, which looks like (hasheq 'messageId "<...@smtp-relay.mailin.fr>").
The sender must be a verified sender (or on an authenticated domain) in your Brevo account. Otherwise Brevo accepts the request but doesn’t deliver the email, and the reason only shows up in Brevo’s logs.
3 Reference
procedure
(brevo-send-email client #:sender sender #:to to [ #:cc cc #:bcc bcc #:subject subject #:html-content html-content #:text-content text-content #:reply-to reply-to #:headers headers #:template-id template-id #:params params #:tags tags]) → jsexpr? client : brevo? sender : string? to : (listof string?) cc : (listof string?) = '() bcc : (listof string?) = '() subject : (or/c #f string?) = #f html-content : (or/c #f string?) = #f text-content : (or/c #f string?) = #f reply-to : (or/c #f string?) = #f headers : (or/c #f (hash/c symbol? string?)) = #f template-id : (or/c #f exact-nonnegative-integer?) = #f params : (or/c #f (hash/c symbol? string?)) = #f tags : (or/c #f (listof string?)) = #f
Addresses can be plain ("jane@example.com") or include a name ("Jane Doe <jane@example.com>"). If reply-to isn’t given, replies go to sender.
At least one of html-content or text-content is required; otherwise exn:fail:user is raised. If Brevo rejects the request (for example, because of an invalid API key), exn:fail is raised with Brevo’s error response as its message.
The other arguments map directly to the fields of Brevo’s send a transactional email endpoint.
parameter
(brevo-host) → string?
(brevo-host host) → void? host : string?
= "api.brevo.com"
parameter
(brevo-port port) → void? port : exact-positive-integer?
= 443
parameter
(brevo-ssl?) → boolean?
(brevo-ssl? ssl?) → void? ssl? : any/c
= #t