jorgemanrubia / mailgun_rails

Rails Action Mailer adapter for Mailgun
MIT License
210 stars 70 forks source link

RestClient::ResourceNotFound (404 Resource Not Found) #58

Open iamraffe opened 8 years ago

iamraffe commented 8 years ago

I have deployed my app to Digital Ocean and while it seems to work correctly in development, in production I keep getting that message.

Any ideas as to why that might be happening?

I should also mention, this is happening with Devise, upon confirming the account.

bsodmike commented 8 years ago

Just tested this with a Rails 5 app, not seeing any issues here.

johny commented 8 years ago

I can confirm, I am also seeing this issue

foysalit commented 8 years ago

Seeing the same error myself. I'm running ubuntu 14.04 on digitalocean. rails 4.2.6 and mailgun_rails 0.8.0.

ArielAleksandrus commented 8 years ago

So no developpers came here to say anything? Could you solve your problem?

foysalit commented 8 years ago

@ArielAleksandrus no response from the maintainers so far. I'm quite new to rails and have no idea even where to start looking at. otherwise, I would be happy to submit a PR with a fix.

atomkirk commented 8 years ago

I'm seeing this with Rails 5 on Heroku. The problem is that RestClient offers NOTHING to help debug this. It simply prints RestClient::ResourceNotFound (404 Resource Not Found): to the logs and then…nothing

atomkirk commented 8 years ago

PR to log specific error response from mailgun: https://github.com/jorgemanrubia/mailgun_rails/pull/67

garybunofsky commented 8 years ago

Also experiencing this issue with Rails 4.2.3 on Heroku.

bsodmike commented 8 years ago

@garybunofsky could you confirm that your Mailgun config is setup correctly?

garybunofsky commented 8 years ago

As far as I know it is. I have mailgun_api_key, mailgun_domain and mailgun_sender set in my secrets.yml. My production.rb has the following to override actionmailer:

config.action_mailer.delivery_method = :mailgun config.action_mailer.mailgun_settings = { api_key: Rails.application.secrets.mailgun_api_key, domain: Rails.application.secrets.mailgun_domain }

Is any of that improper? Could having gem 'mailgun-ruby', '1.1.0', require: 'mailgun' and gem 'mailgun_rails' in my Gemfile be the issue?

bsodmike commented 8 years ago

Hmm, my stack is deployed via Chef (AWS OpsWorks) and I template those setting via env vars, here's an example: - this keeps the keys outside the code-base (and git tracking), which is very important!

# production.rb

  config.action_mailer.delivery_method = :mailgun
  config.action_mailer.mailgun_settings = {
    api_key: ENV['MAILGUN_API_KEY'],
    domain: ENV['MAILGUN_DOMAIN']
  }

As an aside, here's my secrets.yml

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

My Gemfile.lock shows mailgun_rails (0.8.0) and the Gemfile just has gem 'mailgun_rails'.

I'd suggest as a starting point, drop into a console in production and test to see what Rails.application.secrets.mailgun_api_key and mailgun_domain give you.

Then, try forcing v0.8.0, and see if that does anything differently.

So far, mailgun is working find here, latest Rails 5 app too.

garybunofsky commented 8 years ago

Thanks @bsodmike. I did what you suggested and used environment variables instead of Rails.application.secrets. I'm no longer getting the RestClient::ResourceNotFound (404 Resource Not Found): error. I appreciate your help.

For anyone else experiencing this issue and using using devise, make sure your devise.rb has the proper sender. e.g. config.mailer_sender = ENV["MAILGUN_SENDER"]

bsodmike commented 8 years ago

Fantastic, thanks! :metal:

naterexw commented 7 years ago

I had to use the following ENV variables to get mine to work:

  config.action_mailer.mailgun_settings = {
    api_key: ENV["MAILGUN_API_KEY"],
    domain: ENV["MAILGUN_DOMAIN"],
    user_name: ENV["MAILGUN_SMTP_LOGIN"],
    password: ENV["MAILGUN_SMTP_PASSWORD"]
  }
darrenterhune commented 7 years ago

@naterexw errr I don't see user_name or password here https://github.com/jorgemanrubia/mailgun_rails/blob/master/lib/mailgun_rails/client.rb#L8-L12 so those are not doing much 😝

Faisal-nfl commented 5 years ago

Thanks @bsodmike. I did what you suggested and used environment variables instead of Rails.application.secrets. I'm no longer getting the RestClient::ResourceNotFound (404 Resource Not Found): error. I appreciate your help.

For anyone else experiencing this issue and using using devise, make sure your devise.rb has the proper sender. e.g. config.mailer_sender = ENV["MAILGUN_SENDER"]

whats meant by MAILGUN_SENDER here? like mailgun or domain?

bsodmike commented 5 years ago

@Faisal-nfl it'll be the default reply mail address such as "noreply@mydomain.com"