SMTP relay integration

How to integrate with the Brevo SMTP

SMTP is the Simple Mail Transfer Protocol which is used to send emails from an email client through our relay server you can send messages such as eCommerce confirmation orders, password resets or account creations.

SMTP credentials

You can retrieve your SMTP password and username by accessing the top-right menu, click on SMTP and API. Under the "SMTP" tab you can copy the credentials or generate new ones.

❗️

Important

Make sure you are using an SMTP key and not an API key.

  • Port:
    • For non-encrypted connections, between your website and Brevo SMTP, use ports 587 or 2525.
    • For encrypted connections, use port 465 with SSL or TLS encryption.
  • Encryption:
    • Leave this field empty unless you are using port 465, for which you should use SSL or TLS encryption.

SMTP parameters

Below all the message params for the smtp relay.

AttributesDatatypeDescriptionValue
senderObjectMandatory if templateId is not passed. Pass name (optional) and email or id of sender from which emails will be sent. name will be ignored if passed along with sender id. For example,
{"name":"Mary from MyShop", "email":"[email protected]"}
{"id":2}
The sender contains name, email and id
toArray of objectsMandatory if messageVersions are not passed, ignored if messageVersions are passed
List of email addresses and names (optional) of the recipients. For example,
[{"name":"Jimmy", "email":"[email protected]"}, {"name":"Joe", "email":"[email protected]"}]
The receiver contains name and email
bccArray of objectsList of email addresses and names (optional) of the recipients in bccContains name and emails of recipients
ccArray of objectsList of email addresses and names (optional) of the recipients in ccContains name and emails of recipients
htmlContentStringHTML body of the message. Mandatory if 'templateId' is not passed, ignored if 'templateId' is passed
textContentStringPlain Text body of the message. Ignored if 'templateId' is passed"Any text content"
subjectStringSubject of the message. Mandatory if 'templateId' is not passed"Your order has been returned"
replyToObjectEmail (required), along with name (optional), on which transactional mail recipients will be able to reply back. For example,
{"email":"[email protected]", "name":"Ann"}
Consists of name and email of receiver
attachmentArray of objectsPass the absolute URL (no local file) or the base64 content of the attachment along with the attachment name. Mandatory if attachment content is passed. You can find further examples on the API reference in developer dashboardContains url of the attachment, content base64 encoded and the image name
headersObjectPass the set of custom headers (not the standard headers) that shall be sent along the mail headers in the original email. You can find further detail on headers in the API reference"newKey":"newValue"
templateIdInt64Id of the template2
paramsObjectPass the set of attributes to customize the template. For example, {"FNAME":"Joe", "LNAME":"Doe"}. It's considered only if template is in New Template Language format."first_name":"John"
messageVersionsArray of objectsYou can customize and send out multiple versions of a mail. Check further information in the API referenceContains multiple message versions but with same parameters as sender and receiver
tagsArray of stringsTag your emails to find them more easilytag1
scheduledAtdate-timeUTC date-time on which the email has to schedule (YYYY-MM-DDTHH:mm:ss.SSSZ). Prefer to pass your timezone in date-time format for scheduling. There can be an expected delay of +5 minutes in scheduled email delivery. Please note this feature is currently a public beta.2022-04-05T12:30:00+02:00
batchIdStringValid UUIDv4 batch id to identify the scheduled batches transactional email. If not passed we will create a valid UUIDv4 batch id at our end.5c6cfa04-eed9-42c2-8b5c-6d470d978e9d

sender object attributes

AttributeDatatypeDescriptionValue
nameStringName of the sender from which the emails will be sent. Maximum allowed characters are 70. Applicable only when email is passed.Mary from MyShop
emailStringEmail of the sender from which the emails will be sent. Mandatory if sender id is not passed.[email protected]
idInt64Id of the sender from which the emails will be sent. In order to select a sender with specific pool of IP’s, dedicated ip users shall pass id (instead of email). Mandatory if email is not passed.2

to object attributes

AttributeDatatypeDescriptionValue
emailStringEmail address of the recipient[email protected]
nameStringName of the recipient with maximum allowed characters 70Jimmy

bcc object attributes

AttributeDatatypeDescriptionValue
emailStringEmail address of the recipient[email protected]
nameStringName of the recipient with maximum allowed characters 70Helen

cc object attributes

AttributeDatatypeDescriptionValue
emailStringEmail address of the recipient[email protected]
nameStringName of the recipient with maximum allowed characters 70Ann

replyTo object attributes

AttributeDatatypeDescriptionValue
emailStringEmail address of the recipient[email protected]
nameStringName of the recipient with maximum allowed characters 70Ann

attachment object attributes

AttributeDatatypeDescriptionValue
urlUrlAbsolute url of the attachment (no local file).https://attachment.domain.com/myAttachmentFromUrl.jpg
contentStringBase64 encoded chunk data of the attachment generated on the flyb3JkZXIucGRm
nameStringRequired if content is passed. Name of the attachmentmyAttachment.png

headers object attributes

The headers object consists of a string field which contains newKey and a newValue. The newKey is the name of the header you want to include in the request and newValue is the value you assign to that header.

πŸ“˜

SMTP relay and API endpoints

There is something important to note that the SMTP relay does not allow batch sending which can be attempted through the batch sending API endpoints. The SMTP relay is specifically designed to cater to the Transactional emails.

πŸ’‘

Good to know

If you are not able to authorise the domains, and to improve the deliverability of your B2B (Business to business) emails, you can consult the Brevo IP ranges from the help center.