postmark-php
postmark-php copied to clipboard
PostmarkException Code 406: Parsing Message to get inactive emails
I am receiving a PHP exception: PostmarkException 406 from the API. In that exception there is a message which indicates what emails are inactive. Currently I have to parse the message to get the emails so I can do some processing on my end. Would it be possible to throw a new exception called PostmarkInactiveRecipientException that has a property called $recipients which stores the array of inactive emails.
The current exception message:
You tried to send to a recipient that has been marked as inactive. Found inactive addresses: [email protected], [email protected]. Inactive recipients are ones that have generated a hard bounce, a spam complaint, or a manual suppression.
I just ran into another use case where I had to parse the message from the object received from $result = $client->sendEmail() in order to get the inactive emails.
It would be really nice to have a consistent way to get the status of each email involved in the email transaction. I recommend the following:
- A way to send in a flag to the API that always processes all emails and sends an object in the result object that has the email and the delivery status ie:
$result->recipients = [
[ "email"=>"[email protected]", "status"=>"success", "message"=>"", "type"=>"to"],
[ "email"=>"[email protected]", "status"=>"failed", "message"=>"Hard bounce...", "type"=>"cc"]
]
If there are multiple emails recipients the entire email should not fail if one fails because they are on the suppression list.
- The other option is a way to by bass the suppression list feature and let the web hook take care of failed emails. This is working well currently. My biggest issue is there are 3 use cases I have consider and 2 involved parsing a message which is not ideal. I prefer to by pass the suppression list instant failure feature as it doesn't allow all the email recipients to have a chance to receive the email.