Inquiry Regarding Adding Tags to Transactional Emails via Brevo SMTP with Mailwizz

translinguist

New Member
I am facing a challenge in understanding how to add tags with transactional emails sent using Brevo SMTP in conjunction with Mailwizz for our email campaigns.

Brevo support said You can pass the Tag details in the following format:
For SMTP

"X-SIB-API": "{\"params\": {\"NAME\": \"suresh\"},\"tags\":[\"xtag3\", \"xtag4\"], \"templateId\": w}"

I've attempted to incorporate the tag Brevo provided into the HTML of my email template. But unfortunately despite sending several messages, Brevo still isn't recognizing my tag. I beleive, I didn't include it in a proper way, can you please see the details below in my email template and tell me how to fix this?

Here is the updated script that I included in my email:
<script>
var headers = new Headers();
headers.append("X-SIB-API", '{"tags":["latin-america", "south-america"]}');
</script>


here is the updated HTML template:

<!DOCTYPE html>
<html>
<head><meta charset="utf-8"/>
<title></title>
</head>
<body><script>
var headers = new Headers();
headers.append("X-SIB-API", '{"tags":["latin-america", "south-america"]}');
</script><span style="font-size:14px"><span style="font-family:Arial,Helvetica,sans-serif">Hi [FNAME] - CONFIDENTIAL.<br />
<br />
CONFIDENTIAL</span></span><br />
<br />
<span style="font-size:14px"><span style="font-family:Arial,Helvetica,sans-serif">-Sarah<br />
<b>_____________________________</b><br />
<font color="#000090">CONFIDENTIAL</font><br />
Sales Account Manager<br />
<br />
<strong>US</strong> CONFIDENTIAL </span> </span><br />
<br />
<span style="font-size:10px"><span style="font-family:Arial,Helvetica,sans-serif">We value your privacy. If you have received it in error or would like to <a href="mailto:CONFIDENTIALsubject=Unsubscribe">unsub</a> from our mailing list, kindly reply to this email.</span></span></body>
</html>

Could you kindly provide guidance on how I can seamlessly add tags to our transactional emails?

Thanks!
 
While your example is not correct, it doesn't matter either, because MailWizz's implementation does not give you the option to add custom headers, tags, etc to transactional emails, so if you need to do that, you have to do it outside mailwizz, with a direct implementantion between your code and brevo.
 
you have to do it outside mailwizz, with a direct implementantion between your code and brevo.
Thank you for your response @twisted1919
Brevo support suggested that tags can be added in the following format for SMTP:

"X-SIB-API": "{\"params\": {\"NAME\": \"suresh\"},\"tags\":[\"xtag3\", \"xtag4\"], \"templateId\": w}"

And for API, it can be passed in the body details like this:

{
"sender": { "email": "example@gmail.com" },
"to": [ { "email": "example2@sendinblue.com" } ],
"attachment": [ { "url":"abc" } ],
"htmlContent": "hii",
"tags": [ "test" ],
"params": { "name": "test" },
"subject": "hi",
"increaseRecipientLimit": false
}

However, since I'm using SMTP configuration as the delivery server, I'm unsure how to proceed with adding these tags. Could you please provide guidance on how to implement this or suggest a workaround to achieve the desired outcome?

Your assistance on this matter would be greatly appreciated.
 
Sure, for SMTP it should work with a hook, by creating a file named init-custom.php in the apps/ folder with this content in it:
PHP:
<?php
    
    hooks()->addFilter('delivery_server_before_send_email', function(array $params, DeliveryServer $server) {
    
    // I used smtp.sendinblue.com as hostname,
    // you use whatever brevo is giving you
    if ($server->hostname == 'smtp.sendinblue.com') {
        if (!isset($params['headers'])) {
            $params['headers'] = [];
        }
        
        $params['headers'][] = [
            'name' => 'X-SIB-API',
            'value' => '{"params": {"NAME": "suresh"}, "tags":["xtag3", "xtag4"], "templateId": "w"}',
        ];
    }
    
    return $params;
});
This should check each delivery server when an email goes out, no matter from where, and if the hostname is the one I specified, will inject that custom header.
 
I forgot to mention, if you don't need to do this programatically, you can edit your delivery server and add a custom header, use X-SIB-API as the header name and as the header value {"params": {"NAME": "suresh"}, "tags":["xtag3", "xtag4"], "templateId": "w"} .
 
Hello, I've followed your instructions and inserted the tags into the delivery server. However, when I initiate a campaign, Brevo doesn't display any tags in the logs. Do you know if there's an extra step required aside from adding a header in the delivery server?

1709712793186.png
 
This should suffice, you can also try the code example, but I doubt you will get any different response.
You can also try adding another header, for testing, and then check the emails you receive and see if that header is there in the email.
 
Back
Top