ActiveCampaign/postmark-php

[6.0] Custom headers not valid when sending as model

Closed this issue · 2 comments

First go at sending a message as a PostmarkMessage.

If you have a message as an array, e.g.:

$message = [
            'From' => "<someone@example.com>",
            'To' => '<someoneelse@example.com>',
            'ReplyTo' =>'<them@example.com>',
            'Subject' => 'This is a PostmarkMessage test',
            'HtmlBody' => '<p>All the html</p>,
            'TextBody' => 'Text',
            'Attachments' => [],
            'MessageStream' => 'transactional',
            'Metadata' => [
                'person_id' => 4
            ],
            'Headers' => [
                'X-OCA' => 'this is a value'
            ]
];

And create and send a PostmarkMessage model using

$postmarkMessage = new PostmarkMessage($message);
$postmarkClient->sendEmailModel($postmarkMessage);

I get a 422 response with the message:

Invalid request field(s): $.Headers

I'm going to guess that the format of the headers array isn't correct. Is the sendEmailModel method missing a $this->fixHeaders()?

I have a fix for this and I updated the unit tests to ensure it is covered moving forward.

Closing this because of the fix released in v6.0.1