Skip to main content

Ruby SDK

The jetemail gem is the official Ruby and Rails SDK for JetEmail transactional email (MIT license, Ruby 2.6+, HTTParty 0.21+). Create a transactional API key in the dashboard: Outbound → Keys → Add API key. Use that key with the SDK.
Using Rails? The gem registers an ActionMailer delivery method automatically. See Rails integration below.

Installation

Or add to your Gemfile and run bundle install:
Gem on RubyGems: jetemail. Source on GitHub: jetemail/jetemail-ruby.

Quick start

Use a from address on a verified domain (see Getting started).

Configuration

The SDK is configured once at the module level; there is no client object to instantiate.
JetEmail.config is an alias for JetEmail.configure. The API key is read on every request, so it can be set (or changed) at any point before a call. To point the SDK at a different base URL, set the JETEMAIL_BASE_URL environment variable before the gem is loaded (default https://api.jetemail.com). There is no base_url configuration option. The SDK exposes three modules:

JetEmail::Emails.send(params)

Send a single email. params is a plain Hash (symbol keys, snake_case) using the same field names as the REST API.
The Hash is serialized to JSON and sent to the API as-is, so any other field the POST /email endpoint accepts can be included too.

Responses

Every call returns the parsed JSON response as a Hash with symbol keys (result[:id], not result["id"]). Response shape for a single send: { id: String, response: String }.

JetEmail::Batch.send(emails)

Send up to 100 emails in one request. Each element uses the same fields as a single send. Returns summary (total, successful, failed) and results per message (success with id, or error with error).

Error handling

API errors (HTTP 4xx/5xx) raise a subclass of JetEmail::Error. Every error exposes message, status_code (HTTP status) and headers (response headers). Calling the API without an API key set, or receiving a non-JSON response, also raises a JetEmail::Error. Network and transport failures are not wrapped and surface as the underlying HTTParty/Net::HTTP exceptions. InvalidRequestError, NotFoundError and RateLimitError inherit from JetEmail::Error::ClientError; InternalServerError inherits from JetEmail::Error::ServerError.
Common status codes: 400 invalid request, 401 bad/missing API key, 500 server error.

Webhook signature verification

The SDK includes a helper for verifying webhook signatures. It checks the HMAC-SHA256 signature and rejects events whose timestamp is older than the tolerance (default 300 seconds). It returns true on success and raises JetEmail::Error on failure.

Managing webhooks

JetEmail::Webhooks also wraps the webhook management endpoints. Each method returns the parsed JSON response as a Hash with symbol keys.
See Webhook events for the list of event types.

Rails integration

When Rails and ActionMailer are loaded, the gem registers a :jetemail delivery method. Set your API key in an initializer and select the delivery method per environment:
Then use ActionMailer as normal:
The delivery method maps from, to, cc, bcc, reply_to, subject, text/HTML parts, custom headers and attachments to a single JetEmail::Emails.send call, and sets the message’s message_id to the returned JetEmail id.
For additional examples, see the README on GitHub. REST details: API reference.