ActiveCampaign / laravel-postmark-provider

A Postmark adapter for Laravel 5+
30 stars 9 forks source link

Catching PostMark Exceptions #6

Open maximusblade opened 8 years ago

maximusblade commented 8 years ago

Where is the best way to catch these kinds of errors?

GuzzleHttp\Exception\ClientException: Client error: `POST https://api.postmarkapp.com/email` resulted in a `422 Unprocessable Entity` response:
{"ErrorCode":406,"Message":"You tried to send to a recipient that has been marked as inactive.\nFound inactive addresses (truncated...)
atheken commented 8 years ago

@maximusblade Unfortunately, because we funnel through Laravel's mail processing system, sending messages is basically "fire and forget", there's no way for our mail provider to back-channel this error through the normal Laravel code.

Since Laravel has SMTP support built in, we are currently recommending sending with Postmark via the built in SMTP support, instead of using this plugin.

That said, we ran into a similar issue with the way that wp_mail works in our Wordpress plugin.

Since wp_mail doesn't return error codes, we added a static property in our Postmark class that has the "last error" assigned. This is not ideal, but can provide a mechanism for seeing if a send failed. Would a similar mechanism added to the Laravel Postmark provider be helpful to you?

jefferson333 commented 8 years ago

Hello!

What the best way to send email with template in Laravel 5.3 with Postmark API (sendEmailWithTemplate function)?

wildbit/laravel-postmark-provider doesn't work with Laravel 5.3 and by SMTP is not possible work with Postmark templates.