Search code examples
phpmailjet

How to send a test email with personnalmessage in Mailjet campaign


I have a campaign and I send it with $mj->post to a contact list.

But I want to manage a test with the following code from the API

$response = $mj->post(Resources::$NewsletterTest, ['id' => $idNewsletter, 'body' => $body]);

But then I define the $body with a personnalmessage like this :

$body = [
    'Recipients' => [
        [
            'Email' => "myemail@myemail.com",
            'Name' => "John",
            'Vars' => [ 
            'personalmessage' => "Hello John this is a test"
            ]
        ]
    ]
];

I get the follwing error :

"Invalid json input:
object ".Recipients..item"->"TTestRecipient" has no property "Vars"" ["StatusCode"]=> int(400) 

And I do not understand how to correct the problem


Solution

  • When using NewsletterTest, you can specify only email address and name for the test recipients and can not use variables - https://dev.mailjet.com/email-api/v3/newsletter-test/

    Personalisation is only available in Send API only - https://dev.mailjet.com/guides/#personalisation