سؤال

I already have mail working if i use gmail with action mailer in my production.rb file like this:

config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 25,
    domain: "avidest.com",
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: ENV['GOOGLEU'],
    password: ENV['GOOGLEP']
}

I am trying to set it up with mail chimp like this:

config.action_mailer.smtp_settings = {
    :address   => "smtp.mandrillapp.com",
    :port      => 25,
    :user_name => "david@dave23.com",
    :password  => ENV['MAILCHIMP_API_KEY']
}

For some reason, the email is not being sent when i change it from gmail to mail chimp. I know my mail chimp account works because I have been using it with a non-ruby website for a while.

Here are some more of the settings in the production.rb file:

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"
config.action_mailer.default_url_options = { :host => 'myappname.herokuapp.com' }

How do I get mail chimp to work with ruby on rails?

Here are the heroku logs:

2014-03-04T18:09:39.503235+00:00 app[web.1]: I, [2014-03-04T18:09:35.270759 #2]  INFO -- : Processing by Devise::RegistrationsController#create as HTML
2014-03-04T18:09:39.503235+00:00 app[web.1]: I, [2014-03-04T18:09:35.270956 #2]  INFO -- :   Parameters: {"utf8"=>"✓", "authenticity_token"=>"tT4VAL8zcsYCMINkp6WFN+OUO8c4lQQF5r8CtS2X43w=", "user"=>{"email"=>"pghrpg@gmail.com", "profile_name"=>"fsfadljkh", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "first_name"=>"phil", "last_name"=>"greenwald", "how_did_you_hear"=>"Google", "company"=>"", "title"=>"", "type"=>"Employer"}, "commit"=>"SIGN UP!"}
2014-03-04T18:09:39.503235+00:00 app[web.1]: I, [2014-03-04T18:09:36.407845 #2]  INFO -- :   Rendered devise/mailer/confirmation_instructions.html.erb (1.6ms)
2014-03-04T18:09:39.503235+00:00 app[web.1]: I, [2014-03-04T18:09:39.132870 #2]  INFO -- : 
2014-03-04T18:09:39.503235+00:00 app[web.1]: Sent mail to pghrpg@gmail.com (2722.0ms)
2014-03-04T18:09:39.503235+00:00 app[web.1]: I, [2014-03-04T18:09:39.145575 #2]  INFO -- :      Redirected to http://nameless-escarpment-1084.herokuapp.com/
2014-03-04T18:09:39.503601+00:00 app[web.1]: I, [2014-03-04T18:09:39.145918 #2]  INFO -- : Completed 302 Found in 3875ms (ActiveRecord: 150.2ms)

I have done some tinkering and i see this in my heroku logs:

Net::SMTPAuthenticationError (435 4.7.8 Error: authentication failed):
هل كانت مفيدة؟

المحلول

I'm using Mailchimp and this works for mine.

config.action_mailer.smtp_settings = {
  :address   => "smtp.mandrillapp.com",
  :port      => 587, # ports 587 and 2525 are also supported with STARTTLS
  :enable_starttls_auto => true, # detects and uses STARTTLS
  :user_name => "yourmandrillappnumber@heroku.com",
  :password  => "your_SMTP_password", # SMTP password is any valid API key
  :authentication => 'login', # Mandrill supports 'plain' or 'login'
  :domain => 'example.com', # your domain to identify your server when connecting
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top