-
Notifications
You must be signed in to change notification settings - Fork 72
Messages
Igor Balos edited this page Oct 1, 2018
·
8 revisions
For these API requests you will need to use a server API token. Once you obtain it, you will need to use server API client.
server_token = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
client = Postmark::ApiClient.new(<server token>, http_open_timeout: 15)
List sent messages.
client.get_messages(count: 1, offset: 0)
# => [{:message_id=>"41f03342-xxxx-xxxx-xxxx-558caedb5e82", :to=>[{"Email"=>"[email protected]", "Name"=>nil}], :cc=>[], :bcc=>[], :recipients=>["[email protected]"], :received_at=>"2014-01-15T16:41:22.4533537-05:00", :from=>"\"Postmark\" <[email protected]>", :subject=>"Good Luck With The Gem", :attachments=>[]}]
Retrieve single message details.
Use get_message
to get details for a specific message using ID:
client.get_message('41f03342-xxxx-xxxx-xxxx-558caedb5e82')
# => {:text_body=>"...", :body=>"...", :message_id=>"41f03342-xxxx-xxxx-xxxx-558caedb5e82", :to=>[{"Email"=>"[email protected]", "Name"=>nil}], :cc=>[], :bcc=>[], :recipients=>["[email protected]"], :received_at=>"2014-01-15T16:41:22.4533537-05:00", :from=>"\"Postmark\" <[email protected]>", :subject=>"Good Luck With The Gem", :attachments=>[]}
Retriveve single message dump content.
Use #dump_message
to get the full message body:
client.dump_message('41f03342-xxxx-xxxx-xxxx-558caedb5e82')
# => {:body=>"..."}
There is also a handy #messages
enumerator allowing you to easily manipulate big data arrays.
client.messages.lazy.select { |m| DateTime.parse(m[:received_at]).day.even? }.first(5)
# => [{...}, {...}]
List processed messages.
client.get_messages(count: 1, offset: 0, inbound: true)
List single processed message details.
client.get_message('41f03342-xxxx-xxxx-xxxx-558caedb5e82', inbound: true)
For additional information about the capabilities of the Postmark API, see Postmark Developers Documentation.
- Email sending
- Test email sending
- Bounces
- Templates
- Templates push
- Server
- Servers
- Message Streams
- Webhooks
- Messages
- Domains
- Sender Signatures
- Stats
- Trigger Tags
- Suppressions
- Data Removals
- Trigger Inbound Rules
- Parsing Inbound
- Using Postmark with Mail library
- Accessing Postmark Message ID
- Error Handling
- Integration Testing
- Troubleshooting
- Known issues and how to resolve them