Mailjet Varables

I am running n8n on railway.app. Facing an issue with Mailjet integration.

I am trying to trigger a Template Email. Email sending is working. But the variables are not being rendered. I dont know if I am doing it right. Here is my node config screenshot.

Here it shows a success, but on mailjet it shows blocked.

However, when the Template Language is turned off, the email is delivered without rendering the variables.

Can someone help me figure out where i went wrong?

Hey @azharumar,

Are the variable names correct or does MailJet show what is incorrect in the template language?

The variable names are correct. Mailjet doesnt give insights to what went wrong or what the API payload was. I am guessing, it is a problem with how the payload is structured. Can correctly say only if there was some way to inspect the n8n request.

This is how Mailjet needs the requesust.

# This call sends a message to the given recipient with vars and custom vars.
curl -s \
  -X POST \
  --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
  https://api.mailjet.com/v3.1/send \
  -H 'Content-Type: application/json' \
  -d '{
    "Messages":[
      {
        "From": {
          "Email": "[email protected]",
          "Name": "Zarnik Accounts"
        },
        "To": [
          {
            "Email": "[email protected]",
            "Name": "passenger 1"
          }
        ],
        "TemplateID": 5033095,
        "TemplateLanguage": true,
        "Subject": "Monthly Statement",
        "Variables": {
    "email_title": "",
    "customer_name": "Valued Customer",
    "closing_balance": ""
    }
      }
    ]
  }'

I have reached out to the Mailjet team as well for assistance.

1 Like

I will set up a Mailjet account and do a test tomorrow.

@Jon That’d be really helpful.

Hi @Jon, Were you able to take a look at this issue?

Hey @azharumar,

I was not, as I had a busy week before taking some off. I am going to look now.

Hi John, Just now I recieved a response from the mailjet team.

They said, all the variables are being received by mailjet properly intact. The reason why the email is being blocked is that there was a missing variable.

Let me look into that, and give you an update here. Thanks for your time.

Hey @azharumar,

That is handy as I was just testing with our test account but it was blocked so I have had to ask Mailjet to unblock it.

Yes so I tested it and they were right. I missed out a variable and that was the reason mailjet has been blocking the emails.

Just for reference, sharing the payload received fron n8n, shared by mailjet’s team.

{  "From": {  "Email": "[email protected]"  },  "Subject": "Monthly Statement",  "TemplateID": 5033095,  "TemplateLanguage": true,  "To": [  {  "Email": "[email protected]"  } ],  "Variables": {  "closing_balance": "100",  "customer_name": "Azhar Umar",  "email_title": "Monthly Statement"  }  } }
1 Like

That is handy to know, Would be great if the MailJet API returned that something was missing if it is needed but there could be something in the API for that already I will take a look.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.