Send email
with Ruby on Rails
Configure Action Mailer for SMTP and every mailer in your app sends through Plunk.
POST/v1/send
200 OK- To
- ana@acme.com
- From
- Acme <hello@acme.com>
- Subject
- Reset your password
Reset your password
To ana@acme.com
- Sent09:41:02
- Delivered09:41:03
- Opened09:42:18
Before you send
Create a project
Sign up for free and copy your secret key from the project settings.
Verify your domain
Add the DNS records Plunk shows you. It checks them and tells you when you can send.
Send
Use the API or your framework’s mailer, below. Every email shows up in the dashboard.
Send with Ruby on Rails over SMTP
Add the SMTP settings to your production environment. Your mailers stay exactly as they are.
config/environments/production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.useplunk.com",
port: 587,
user_name: "plunk",
password: ENV["PLUNK_SECRET_KEY"],
authentication: :plain,
enable_starttls_auto: true
}Send with the API
Use the API from Ruby’s standard library when you want Plunk templates or workflows.
app/services/plunk.rb
require "net/http"
require "json"
uri = URI("https://send-api.akmarketingseo.com/v1/send")
request = Net::HTTP::Post.new(
uri,
"Content-Type" => "application/json",
"Authorization" => "Bearer #{ENV["PLUNK_SECRET_KEY"]}"
)
request.body = {
to: "ana@acme.com",
subject: "Welcome to Acme",
body: "<p>Thanks for signing up.</p>"
}.to_json
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
raise "Plunk returned #{response.code}" unless response.is_a?(Net::HTTPSuccess)Frequently asked questions
Send your first email from Ruby on Rails.
Start on the free plan with 1,000 emails a month, no credit card needed. When you need more, every email is $0.001, with unlimited contacts and every feature included.