Skip to content

Commit f5ee65f

Browse files
committed
InactiveRecipient for PMMail class
1 parent f4920c2 commit f5ee65f

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

postmark/core.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,13 @@ def send(self, test=None):
470470
jsontxt = err.read().decode()
471471
jsonobj = json.loads(jsontxt)
472472
desc = jsonobj['Message']
473-
except:
474-
desc = 'Description not given'
473+
error_code = jsonobj['ErrorCode']
474+
except KeyError:
475+
raise PMMailUnprocessableEntityException('Unprocessable Entity: Description not given')
476+
477+
if error_code == 406:
478+
raise PMMailInactiveRecipientException('You tried to send email to a recipient that has been marked as inactive.')
479+
475480
raise PMMailUnprocessableEntityException('Unprocessable Entity: %s' % desc)
476481
elif err.code == 500:
477482
raise PMMailServerErrorException('Internal server error at Postmark. Admins have been alerted.', err)

0 commit comments

Comments
 (0)