The ApiClient provides several methods for sending emails depending on whether you are using templates or raw message hashes.
Sending single messages
deliver(message_hash): Sends a single message using a hash of attributes.deliver_message(message): Sends a message object. Note: This method will raise an ArgumentError if the message is templated. Use deliver_message_with_template instead.deliver_message_with_template(message): Sends a message object that uses a Postmark template.deliver_with_template(attributes): Sends a single message using a hash of attributes including template information.
Sending multiple messages (Batching)
Batching is handled automatically by the client using the configured max_batch_size.
deliver_in_batches(message_hashes): Sends an array of message hashes in batches using the /email/batch endpoint.deliver_messages(messages): Sends an array of message objects. Raises ArgumentError if any message is templated.deliver_messages_with_templates(messages): Sends an array of message objects where all messages must be templated, using the /email/batchWithTemplates endpoint.deliver_in_batches_with_templates(message_hashes): Sends an array of message hashes in batches using the /email/batchWithTemplates endpoint.
# Single message via hash
client.deliver({ from: 'sender@example.com', to: 'rcpt@example.com', subject: 'Hello', text_body: 'World' })
# Single message via object (non-templated)
client.deliver_message(my_message_object)
# Batch of hashes
client.deliver_in_batches([{ from: '...', to: '...', ... }, { from: '...', to: '...', ... }])