Send email with Ruby

Skip the ActionMailer SMTP config. Sending email from Ruby is one POST from Net::HTTP or Faraday, message ID back.

Verified By Kam Low, Co-founder · Updated

ActionMailer config vs one POST

ActionMailer earns its keep for templated app mail inside Rails, but it still rides on SMTP settings: address, port, user_name, password, authentication, enable_starttls_auto. Six config keys before the first send, and rotating credentials touches every environment.

Two places a send can live in a Rails request cycle
Inside the request
request in
send, inline
response out
couples your response time to a third party
In a background job
request in
enqueue jobretry semantics included
response outunaffected
the send happens after the response, on its own clock
Inline, a third party sits inside your response time. A background job gets retries and leaves the response alone.

One POST, and the send is handled

RubyPOST /v1/my/messages
require "net/http"
require "json"

Net::HTTP.post(
  URI("https://api.nitrosend.com/v1/my/messages"),
  { from: "[email protected]", to: "[email protected]",
    subject: "Welcome", html: "<p>You're in.</p>" }.to_json,
  "Authorization" => "Bearer #{ENV['NITROSEND_API_KEY']}",
  "Content-Type" => "application/json",
)

Works from Rails, Sinatra, a Rake task, or a bare script. One env var, standard library only.

For scale of what sits behind that POST: I recently watched four flows and fourteen emails get designed, written, and set sending in about twenty-three minutes. Builders who grew up on Rails scaffolding will recognize the feeling.

And here's the part Ruby people will enjoy: the API on the other end of that POST is a Rails 8.1 app, PostgreSQL and GoodJob underneath. Your Net::HTTP call is speaking to a stack you already know how to reason about.

A design detail from inside that codebase: every production send path, campaign, flow, transactional, and the MCP tool included, runs through one central sending gate, a single check on every dispatch. A paused account fails loudly with metadata saying exactly why, instead of six code paths each deciding for themselves. And when SES suppresses a recipient mid-flow, the failure is written to the send log and that branch stops, without failing the whole GoodJob run. Rails people know why both of those matter.

The email renderer is Ruby too. When an agency customer reported that images set to 50% width came out full size in Gmail, the root cause was our renderer stripping the px unit and re-appending it, so 50% became 50%px. The fix went through nitrosend/api#80 with the image spec at 19 of 19 green, and the supported width shapes are now pinned to exact strings: 300, 300px, 50% and 12.5px preserved, garbage like calc(100%) dropped.

The whole surface is inspectable. The API publishes its own OpenAPI document at api.nitrosend.com/openapi.yaml, a Rails health check at /up, and every REST route under /v1/my. Nothing about the stack is hidden from the person integrating it.

Full parameters, responses, and error codes live in the REST API docs and the API reference.

Python Node.js PHP Go Rust +5
send.py requests ยท stdlib-adjacent
import requests

requests.post(
  "https://api.nitrosend.com/v1/messages",
  headers={"Authorization": f"Bearer {KEY}"},
  json={"to": to, "subject": subj,
        "html": body})
202 ACCEPTED
{ "id": "msg_9f2c",
  "status": "accepted" }

And the part no library gives you

The same account exposes an MCP server, so the agent writing your code can also run your email. Point Claude, Cursor, or Codex at api.nitrosend.com/mcp and it composes, previews, and stages sends, with a human approving every one. The API is for your code. The MCP is for your agent. One platform either way.

Every send comes back with a message ID, and delivery events follow on your webhook: delivered, opened, bounced. No dashboard required to know what happened. If you are staying on SMTP, how to set up SMTP is the setup to follow, and SPF, DKIM and DMARC authentication is what stops those sends landing in spam.

Net::SMTP or a gem is a Ruby developer's call to make, and it always has been. It increasingly isn't a developer making it. Point Claude, Cursor, or Codex at our MCP server and the agent composes the send, picks the transport, and asks you to approve it before it leaves. I think that's the real direction email sending is heading, and it's why Nitrosend is a listed app in the ChatGPT app marketplace rather than one more gem to bundle install.

Go deeper

Guides

FAQ

How do I send email from Ruby?

POST to the email API with Net::HTTP or Faraday: JSON body, bearer token header, message ID back. No SMTP settings block, no delivery mystery.

Can I keep ActionMailer?

Yes, point its delivery method at the API or keep it for templating and deliver through the REST endpoint. The win is dropping SMTP credentials and gaining delivery events.

First send in thirty seconds.

Simple pricing. Unlimited contacts.

Every plan includes full stack emailing: Flows, Newsletter Campaigns and Transactional Email, plus our NitroWheel LLM and all agent integrations (Claude, ChatGPT, Codex, Cursor and others). Pay for what you send, not who you store.

Daily allowances depend on your plan and sender standing. Strong list, domain and delivery evidence can raise standing, including on day one. Trusted receives the full plan allowance; available email credits, safety checks and delivery pacing still apply.

Free
$0
forever
  • Emails 8,000then 500/mo
  • Email types Transactional & Marketing
  • AI actions 20/mo
  • Contacts Free & Unlimited
  • Brands 3
  • Seats 1
  • Recipients / rolling 24h 100โ€“5,000
  • Email validation Prepaid only
Start free
Ultra
$100
per month
  • Emails 125,000/month
  • AI actions 5,000/mo
  • Brands 10
  • Seats 10 · Domains 10
  • Frontier AI Included
  • Dedicated IP Available
  • Recipients / rolling 24h 1,000โ€“625,000
  • Email validation Prepaid only
Get started
Enterprise
$300
per month
  • AI actions Unlimited
  • Unlimited brands & domains Included
  • SSO / SAML Included
  • 99.9% SLA Included
  • Recipients / rolling 24h Contracted
  • Email validation Prepaid only
Get started

Free forever. No credit card required. See full comparison →