简体   繁体   中英

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 = 'no-reply@sociedadeavalia.com.br'
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?

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.

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

:authentication => 'plain',

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM