RBrandao
RBrandao

Reputation: 142

Send Devise E-mails using Mandrill in Production

I'm trying to send the Devise e-mails from my Rails 4 app. I don't want to change the templates or anything, I just want to use Mandrill to deliver the messages in the production environment.

My production.rb is like this:

  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default_url_options = {:host => 'sociedadeavalia.com.br'}
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :address => "smtp.mandrilapp.com",
    :port    => 587,
    :user_name => ENV['MANDRILL_USERNAME'],
    :password => ENV['MANDRILL_APIKEY'],
    :authentication => 'login',
    :enable_starttls_auto => true,
    :domain  => 'sociedadeavalia.com.br'
  }

I have this in my devise.rb

config.mailer_sender = '[email protected]'
config.mailer = 'MyDeviseMailer'

And I created the following mailer:

class MyDeviseMailer < Devise::Mailer
  helper :application
  include Devise::Controllers::UrlHelpers
  default template_path: 'devise/mailer'  
end

Now Whenever i try to send an email in production (the confirmation email for creating a new user account) my app just crashes and this appears in the log:

31 <190>1 2014-12-03T22:17:07.987969+00:00 app web.1 - - Net::OpenTimeout (execution expired):

What should I do in this case?

Upvotes: 0

Views: 440

Answers (2)

Kaitlin
Kaitlin

Reputation: 6235

It looks like you might be having an issue with the port being blocked. We'd recommend the troubleshooting steps here. More specifically, try changing the port you're using - 2525 is often not blocked, or use 465 with SSL enabled. Many hosts block 25 and 587 to help prevent spam.

Upvotes: 1

Philip Hallstrom
Philip Hallstrom

Reputation: 19879

Try changing the authentication to 'plain'. That is what is working for me.

:authentication => 'plain',

Upvotes: 0

Related Questions