I'm trying to set up mailing from a very simple Rails 3.2 app. Tried Gmail, tried SendGrid. Getting same error.
Net::SMTPAuthenticationError in UsersController#create
530-5.5.1 Authentication Required
Here's my section of environments/development.rb
# Care if the mailer can't send
config.action_mailer.raise_delivery_errors = true
# Change mail delivery to either :smtp, :sendmail, :file, :test
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "signaldesign.net",
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["gmailusername"],
password: ENV["gmailpassword"]
}
Here's my users_controller
def create
@user = User.new(params[:user])
if @user.save
UserMailer.signup_confirmation(@user).deliver
sign_in @user
flash[:success] = "Welcome!"
redirect_to @user
else
render 'new'
end
end
I'm stumped. None of the suggestions I've found online are making a difference.
Meanwhile the gem dotenv changed its implementation. You can now use your
ENV
settings to initialize theActionMailer
. I verified this withdotenv v.0.7.0
. Make sure you load the environment variables. Autoloading has been removed from the gem. Read here.Try changing the domain to
localhost.localdomain
I figured it out. I finally resorted to just deleting things and trying again.
I changed my smtp_settings username and password from:
to