Search code examples
ruby-on-rails-4herokuheroku-api

how to include mail gun API in rails?


I want to use Mailgun in my Rails application.

When I include through Heroku addon it display error to add credit card number though I wanted the free version.

I looked up and found this code from Mailgun. Could someone tell me how to use it?

require 'mail'
Mail.defaults do
  delivery_method :smtp, {
    :port      => 587,
    :address   => "smtp.mailgun.org",
    :user_name => "",
    :password  => "",
  }
end

mail = Mail.deliver do
  to      '[email protected]'
  from    'foo@YOUR_DOMAIN_NAME'
  subject 'Hello'

  text_part do
    body 'Testing some Mailgun awesomness'
  end
end

I tried using this but it displays an error - mailgun SSL_read: sslv3 alert bad record mac


Solution

  • You need to sign up with Mailgun and get your SMTP username and password which you would use in the mail configuration.