Skip to content

Instantly share code, notes, and snippets.

@temochka
Created September 9, 2017 11:10
Show Gist options
  • Save temochka/38844b61edc490b404ce000983d05f13 to your computer and use it in GitHub Desktop.
Save temochka/38844b61edc490b404ce000983d05f13 to your computer and use it in GitHub Desktop.

Template

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <body>
    <center><img src="cid:logo.png"/></center><br/>
    Hello {{name}}!
  </body>
</html>

Ruby code

require 'postmark'
your_api_token = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

client = Postmark::ApiClient.new(your_api_token)
client.deliver_with_template(from: 'test@wildbit.com',
                             to: 'test@wildbit.com',
                             attachments: [{name: 'logo.png',
                                            content: [File.read('logo.png')].pack('m'),
                                            content_type: 'image/png',
                                            content_id: 'cid:logo.png'}],
                             template_id: 3157881,
                             template_model: {
                               name: 'Chris'
                             })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment