Giter VIP home page Giter VIP logo

hubspot-mailer's Introduction

Hubspot Single Send API SDK for use with Ruby on Rails

Wraps the HubSpot Single Send API https://developers.hubspot.com/docs/methods/email/transactional_email.

Documentation for the Single Send API can be found here: https://developers.hubspot.com/docs/methods/email/transactional_email/single-send-overview

Setup

gem install hubspot-mailer

Or with bundler,

gem "hubspot-mailer"

Authentication with an API key

Before using the library, you must initialize it with your HubSpot API key. If you're using Rails, put this code in an initializer:

Hubspot.configure(hapikey: "YOUR_API_KEY")

If you have a HubSpot account, you can get your api key by logging in and visiting this url: https://app.hubspot.com/keys/get

Usage

The usage is the same as for ActionMailer with that difference there is no way to add attachments and a set of additional params.

class ApplicationMailer < Hubspot::Mailer
  default from: "[email protected]"

  def test_mail
    mail(
      to:                 "[email protected]",
      subject:            "Test Email",
      email_id:           123,
      send_id:            SecureRandom.hex(8)
      contact_properties: { first_name: "John", last_name: "Doe" },
      custom_properties:  { property: "Value" }
    )
  end
end

Properties

email_id

The content ID for the transactional email, which can be found in Email Tool UI.

send_id

The ID of a particular send. No more than one email with a given sendId will be send per portal, so including a sendId is a good way to prevent duplicate email sends.

contact_properties

Each property will get set on the contact record and will be visible in the template under {{ contact.NAME }}.

custom_properties

Each property will be visible in the template under {{ custom.NAME }}.

Testing

Add this line to config/environments/test.rb:

Hubspot::Mailer.delivery_method = :test

Now you can use the same ActionMailer::Base.deliveries to read sent emails in your tests.

hubspot-mailer's People

Contributors

heaven avatar lukewduncan avatar dependabot[bot] avatar ur5us avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.