Install
One gem, no runtime dependencies, Ruby 3.2 and up.
Install
The current release is 0.0.1. It has a method for every method of the TypeScript SDK, under the same name in snake_case, and the gem’s parity check fails the build when one goes missing or sends a different request.
bundle add openemailrequire "openemail" OpenEmail.init(api_key: ENV.fetch("OPENEMAIL_API_KEY")) email = OpenEmail.emails.send( from: "Acme Billing <[email protected]>", to: "[email protected]", subject: "Your September invoice", html: "<p>Invoice attached.</p>") puts email[:id], email[:status]OpenEmail.init configures the shared client once, and from then on OpenEmail.emails, OpenEmail.threads and every other namespace use it, in every file. Skip it and the first call builds the client from OPENEMAIL_API_KEY instead.
A response is the parsed JSON as a Hash with Symbol keys, so email[:id] reads the id. The keys keep the API’s names, which is why a field such as scheduledAt stays camelCase while the methods and their options are snake_case.
send returning does not mean the message has gone. A scheduled or cancellable send comes back queued or scheduled and settles later. Read status, not the fact that the call returned.
Where it runs
Ruby 3.2 and up, with no runtime dependencies. The HTTP client is Net::HTTP from the standard library, with a pool of kept-alive connections, so a second request to the API reuses the connection the first one opened.
One client is safe to share across threads, so a Puma or Sidekiq process needs only one. After a fork, as in Puma’s cluster mode, Unicorn or Resque, the child opens connections of its own rather than reusing the parent’s.
The client carries a workspace API key that can send mail and read the mailbox, so it belongs on a server, in a job or in a tool that runs on your own machine. Keep the key in Rails.application.credentials or an environment variable, never in code.