Ruby

Send email from Ruby

gem install mailset, then send_email with keyword arguments. The gem pulls in no other gems, and RBS signatures cover every input and answer.

Open Mailset
Continue with Google

By starting you agree to the Terms and Privacy Policy.

Install

Install the Ruby SDK

gem or Bundler, or the line for your Gemfile. Ruby 3.0 and later.

gem install mailset
Send

Send your first email from Ruby

Mailset::Client.new reads MAILSET_KEY. The method is send_email, because send already belongs to every Ruby object. deliver_by: '10m' refuses a code that can’t leave in ten minutes; the receipt answers sent.id and sent.status, and a refusal raises Mailset::Error.

send.rb
require 'mailset'

mailset = Mailset::Client.new

sent = mailset.send_email(
  from: 'Acme <moc.elpmaxe@olleh>',
  to: 'gro.elpmaxe@ana',
  subject: 'Your Acme code',
  text: 'Your code is 123456.',
  html: '<p>Your code is <b>123456</b>.</p>',
  deliver_by: '10m'
)

puts sent.id, sent.status
Webhooks

Delivery events in Rails

Bounces, complaints and deliveries reach your app as signed posts. The Rails guide has the controller, which verifies request.raw_post and skips the CSRF check that would refuse them.

Domain

Send from your own domain

Your product sends as your own domain either way. What changes is where your team’s mail lives.

  • Sending only. Your team’s mail stays at Google, Microsoft or wherever it is now. Mailset asks for DKIM, a bounce host and DMARC, and leaves your MX alone. Send from a domain whose mail stays elsewhere
  • Mailboxes too. Your team’s mail moves to Mailset, with a real mailbox for every address on the domain and your product’s email on the same bill. Set up a domain
mailset domains add example.com --sendingmailset domains apply example.com --sendingmailset domains check example.commailset keys create --send --domain example.com --from moc.elpmaxe@olleh --name "Acme API"
Facts

What the Ruby SDK’s build checks

Each line comes from the SDK’s own build, which fails when one stops being true.

FactDetailKnown from
Ruby 3.0+The oldest its manifest allowsIts manifest
No dependenciesNothing else to install beside itIts manifest
Typed throughoutModel classes, RBS signatures checkedA test
Next

Where to go from here

Pricing

Product email on every plan

  • Base$29a month10 members included
  • Team$79a month25 members included
  • BaseRegular price $29$14.50a month10 members included
  • TeamRegular price $79$39.50a month25 members included

Black Friday prices, for trials started by Thursday, Dec 31. Offer terms

Both include 10,000 emails a month, your product’s and your team’s together. Past that it’s $0.40 per 1,000 with pay as you go.

Every price, and what teams pay elsewhere

Questions

Sending from Ruby, asked and answered

Why send_email and not send?

Object#send calls any method by name, and plenty of Ruby code relies on it. The SDK leaves it alone: one message is send_email, a batch is send_emails.

Can threads share one client?

Yes. One client is safe to share between threads, so a constant made at boot serves every thread of your server.

Do I need Net::SMTP or the mail gem?

No. The gem posts to Mailset’s HTTPS API with your key, and Mailset builds the MIME. There are no SMTP settings to keep.

How do I send a batch?

send_emails takes an array of hashes with send_email’s keys and answers one result each, a Sent or a NotSent. A refusal never stops the rest, and past 100 messages it splits the calls itself.

Make a key and sendTry it on your own domain

Make a key in Settings › Developers, keep it as MAILSET_KEY, and run the example above.7 days free, with everything on. Make a key, run the example above and watch the receipt come back.

Open Mailset
Continue with Google

By starting you agree to the Terms and Privacy Policy.