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.
Attributes | Datatype | Description | Value |
---|---|---|---|
sender | Object | Mandatory 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 |
to | Array of objects | Mandatory 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 |
bcc | Array of objects | List of email addresses and names (optional) of the recipients in bcc | Contains name and emails of recipients |
cc | Array of objects | List of email addresses and names (optional) of the recipients in cc | Contains name and emails of recipients |
htmlContent | String | HTML body of the message. Mandatory if 'templateId' is not passed, ignored if 'templateId' is passed | |
textContent | String | Plain Text body of the message. Ignored if 'templateId' is passed | "Any text content" |
subject | String | Subject of the message. Mandatory if 'templateId' is not passed | "Your order has been returned" |
replyTo | Object | Email (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 |
attachment | Array of objects | Pass 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 dashboard | Contains url of the attachment, content base64 encoded and the image name |
headers | Object | Pass 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" |
templateId | Int64 | Id of the template | 2 |
params | Object | Pass 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" |
messageVersions | Array of objects | You can customize and send out multiple versions of a mail. Check further information in the API reference | Contains multiple message versions but with same parameters as sender and receiver |
tags | Array of strings | Tag your emails to find them more easily | tag1 |
scheduledAt | date-time | UTC 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 |
batchId | String | Valid 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
Attribute | Datatype | Description | Value |
---|---|---|---|
name | String | Name of the sender from which the emails will be sent. Maximum allowed characters are 70. Applicable only when email is passed. | Mary from MyShop |
email | String | Email of the sender from which the emails will be sent. Mandatory if sender id is not passed. | [email protected] |
id | Int64 | Id 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
Attribute | Datatype | Description | Value |
---|---|---|---|
email | String | Email address of the recipient | [email protected] |
name | String | Name of the recipient with maximum allowed characters 70 | Jimmy |
bcc
object attributes
Attribute | Datatype | Description | Value |
---|---|---|---|
email | String | Email address of the recipient | [email protected] |
name | String | Name of the recipient with maximum allowed characters 70 | Helen |
cc
object attributes
Attribute | Datatype | Description | Value |
---|---|---|---|
email | String | Email address of the recipient | [email protected] |
name | String | Name of the recipient with maximum allowed characters 70 | Ann |
replyTo
object attributes
Attribute | Datatype | Description | Value |
---|---|---|---|
email | String | Email address of the recipient | [email protected] |
name | String | Name of the recipient with maximum allowed characters 70 | Ann |
attachment
object attributes
Attribute | Datatype | Description | Value |
---|---|---|---|
url | Url | Absolute url of the attachment (no local file). | https://attachment.domain.com/myAttachmentFromUrl.jpg |
content | String | Base64 encoded chunk data of the attachment generated on the fly | b3JkZXIucGRm |
name | String | Required if content is passed. Name of the attachment | myAttachment.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.
Updated 11 months ago