Inbound messages

The inbound messages API is available via the messages.inbound manager:

>>> postmark.messages.inbound.all()
[<InboundMessage: Blocked message from>, ...]

There is a simple way to access the headers in the InboundMessage instance:

>>> inbound['X-Spam-Status']

Also, you can convert inbound message to MIME instance:

>>> inbound.as_mime()
<email.mime.multipart.MIMEMultipart object at 0x10a232c88>


To access the attachments you could use the Attachments attribute of the InboundMessage which returns a list of attachments.

>>> inbound.Attachments
[<Attachment: test.txt>]

The interface is the same - all keys-value pairs in JSON data are attributes of the Attachment:

>>> attachment = inbound.Attachments[0]
>>> attachment.Name

Besides it, you could do the following with attachments:

  • Access the decoded content

  • Check it length

  • Save it locally

  • Convert it to MIME instance

>>> len(attachment)
>>> attachment.decoded
This is attachment contents, base-64 encoded.
>>> attachment.as_mime()
<email.mime.base.MIMEBase at 0x10424b7b8>

Outbound messages

The outbound messages API is available via the messages.outbound manager:

>>> postmark.messages.outbound.all()
[<OutboundMessage: Sent message to>, ...]


The opens API handler is located in messages.outbound.opens manager.

>>> postmark.messages.outbound.opens.all()
[<Open: Open from>, ...]

Also, you can access to corresponding OutboundMessage instance via message property.

>>> open.message
<Sent message to>