← All Guides

How to Send Emails with Ruby

Send transactional emails from your Ruby or Rails application using AISend's REST API.

1. Send with Net::HTTP

Use Ruby's standard library to call the API:

require 'net/http'
require 'json'
require 'uri'

uri = URI('https://api.aisend.app/v1/emails')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer as_your_api_key'
request['Content-Type'] = 'application/json'
request.body = {
  from: 'hello@yourdomain.com',
  to: 'user@example.com',
  subject: 'Hello from Ruby',
  html: '<p>Sent with AISend from Ruby.</p>'
}.to_json

response = http.request(request)
puts response.body

2. Rails integration

For Rails apps, create a service object that wraps the AISend API call. Use it from controllers, background jobs, or mailers.

Ready to Start Sending?

1,000 emails/month free. No credit card required.