Email API Integration Guide with Ruby on Rails

Minimum code that you need to integrate Mailazy with your Ruby on Rails application


Prerequisites

You need to complete these given prerequisites, you can skip the step if you have already completed.

  1. Sign up for a Mailazy account.
  2. Complete Domain Authentication.
  3. Generate the Mailazy Access Key

Integrate Mailazy with Ruby on Rails

Start Sending mail using the code provided below:

require "uri"
require "net/http"
url = URI("https://api.mailazy.com/v1/mail/send")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Api-Key"] = "<API KEY>"
request["X-Api-Secret"] = "<API SECRET>"
request["Content-Type"] = "application/json"
request.body = '{
      "to": ["example@example.com"],
      "from": "Sender <sender@example.com>",
      "subject": "<Subject>",
      "content": [{"type": "text/plain","value": "<Content>"}]
}'
response = https.request(request)
puts response.read_body