Skip to content

Getting Started

Igor Balos edited this page Oct 1, 2018 · 18 revisions

Getting started with Postmark is very easy. In order to start using the full potential of Postmark Ruby Gem, you will need to:

Account API token is needed only for admins, for managing account details like domains, signatures, etc. To read more about tokens, check out our developer docs.

Sending your first email

Sending email with Postmark is super easy, check out the following code example.

client = Postmark::ApiClient.new(<server token>, http_open_timeout: 15)

client.deliver(from: '[email protected]',
               to: 'Leonard Hofstadter <[email protected]>',
               subject: 'Re: Come on, Sheldon. It will be fun.',
               text_body: 'That\'s what you said about the Green Lantern.')

# => {:to=>"Leonard Hofstadter <[email protected]>", :submitted_at=>"2013-05-09T02:45:16.2059023-04:00", :message_id=>"b2b268e3-6a70-xxxx-b897-49c9eb8b1d2e", :error_code=>0, :message=>"OK"}

Some useful options are:

  • secure (true or false): set to false to disable SSL connection.
  • http_read_timeout (positive number): limit HTTP read time to n seconds.
  • http_open_timeout (positive number): limit HTTP open time to n seconds.
  • proxy_host (string): proxy address to use.
  • proxy_port (positive number): proxy port to use.
  • proxy_user (string): proxy user.
  • proxy_pass (string): proxy password.

Please note that in in the code example above you need to change <server token> to a server token from your account, and you need to change <sender signature> to a verified signature (from address), you created in your account.

Next, we will check out more advanced sending techniques and other API features. Check out our wiki pages sidebar for details.