Net::SMTPFatalError in MessagesController#create — 550 Cannot receive from specified address : Unauthenticated senders not allowed

I have a rails 4.1.8 app using Devise, Heroku and Sendgrid. Sending emails is part of the apps functionality. Everything works perfectly in development on my laptop that I built the app in. Emails are being sent and received…all is good.

I git cloned the repo on my desktop, and I am getting the above errors.

I have set up all of my ENV variables using the Figaro gem. When I run heroku config on my dev laptop, all of the correct values and variables are present.

Here is my config/initializers/setup_mail.rb file:

if Rails.env.development? || Rails.env.production?
  ActionMailer::Base.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = {
    address:        'smtp.sendgrid.net',
    port:           '587',
    authentication: :plain,
    user_name:      ENV['SENDGRID_USERNAME'],
    password:       ENV['SENDGRID_PASSWORD'],
    domain:         'heroku.com',
    enable_starttls_auto: true
  }
end

I am using the Figaro gem, and have created a config/application.yml file on my dev laptop computer containing my secure ENV variables. As this file is on the .gitignore list, I have also created an config/application.yml file in my desktop computer (the second computer) that looks like this:

SENDGRID_USERNAME:  <%= ENV["SENDGRID_USERNAME"] %>
SENDGRID_PASSWORD:  <%= ENV["SENDGRID_PASSWORD"] %>

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

DEVISE_SECRET_KEY:  <%= ENV["DEVISE_SECRET_KEY"] %>

Again, everything works perfectly in development on my dev laptop, but on my second computer I am getting this error:

Net::SMTPFatalError in MessagesController#create
550 Cannot receive from specified address <support@******.com>: Unauthenticated senders not allowed

Thanks!

  • composer.json specifies dependency, but no composer.lock was found
  • Heroku won't accept push due to submodule
  • One Solution collect form web for “Net::SMTPFatalError in MessagesController#create — 550 Cannot receive from specified address : Unauthenticated senders not allowed”

    Have you tried using the SendGrid Gem?

    The Unauthenticated senders not allowed explicitly means that you’re connecting to SendGrid, but are not attempting to make an AUTH LOGIN command before sending a message. I see you have the authentication defined, but something is keeping it from actually being enabled.

    Git Baby is a git and github fan, let's start git clone.