postmark-php icon indicating copy to clipboard operation
postmark-php copied to clipboard

How to get messageID from sendEmail?

Open kobbe0 opened this issue 3 years ago • 1 comments

I can successfully send e-mail as in your example:

$sendResult = $client->sendEmail(
  "[email protected]",
  "[email protected]",
  "Hello from Postmark!",
  "This is just a friendly 'hello' from your friends at Postmark."
);

But can not figure out how to get messageID from the $sendResult, and not finding any information about it in examples or documenation.

$sendResult becomes object(Postmark\Models\DynamicResponseModel) so can not access it directly.

What is the proper way to extract the result from sendEmail?

kobbe0 avatar Mar 10 '21 08:03 kobbe0

Hi @kobbe0,

You can access properties like:

$sendResult->MessageID or $sendResult["MessageID"] $sendResult->ErrorCode or $sendResult["ErrorCode"]

This syntax will work for any of the properties returned in the send email response (To, SubmittedAt, MessageID, ErrorCode, or Message)

briankerr avatar Mar 10 '21 23:03 briankerr