Rails devise with gmail errors

rails mailer
rails test email
rails test mailer
rails mailer body
rails mail::message
rails email preview
rails email template
actionmailer smtp_settings

I'm currently working on an application with a mailer system. It was working fine, sending a welcome email and sending instructions to reset password, but now and only when I try to send reset instructions I have this error.

ArgumentError (SMTP From address may not be blank: nil):

I'm using a custom domain like so noreply@mycustomdomain.com And here is my configuration

development.rb

 config.action_mailer.raise_delivery_errors = true
 config.action_mailer.perform_caching = false
 config.action_mailer.default_url_options = { host: 'localhost:3000' }

 config.action_mailer.delivery_method = :smtp
 config.action_mailer.smtp_settings = {
     address: 'smtp.gmail.com',
     port: '587',
     domain: 'gmail.com',
     authentication: :plain,
     enable_starttls_auto: true,
     user_name: Rails.application.secrets.mailer_username,
     password: Rails.application.secrets.mailer_password
}

Any idea ?

Edit

class UserMailer < ApplicationMailer
  default from: 'noreply@mycustomdomain.com'

  def welcome_email(user)
    @user = user
    @url = 'http://localhost:3000/users/sign_in'
    mail(to: @user.email, subject: 'Bienvenue')
  end

  def generate_new_password_email
    user = User.find(params[:user_id])
    user.send_reset_password_instructions
  end

  def reset_password; end
end

I had the same problem, and the reason behind that was i working in development but my mailer was searching the smtp_settings in the production, so to solve the issue you can change the mailer settings or you can copy the same smtp_settings into production.

Using Devise with Gmail, SendGrid, Rails and Heroku: Tips to save , Looking back, the majority of the errors I encountered were related to getting the environment variables set, however, the error logs in Heroku's  In this chapter, we'll learn how to send/receive email to/from our minimal application. We're going to use Action Mailer with Devise which a popular, full-fledged authentication. We'll use gmail as a from mail but in next chapter (Rails Heroku Deploy - Authentication and sending confirmation email

You could try setting :from in your config, using the default_option like this,

config.action_mailer.default_options = { from: 'noreply@mycustomdomain.com' }

Rails devise with gmail errors, Rails devise with gmail errors, I had the same problem, and the reason behind that was i working in development but my mailer was searching the smtp_settings​  I am trying to create a contact form in Rails 4. I did some digging around here and was able to get most of the stuff to work. (followed @sethfri's work here Contact Form Mailer in Rails 4) Right

It looks like you don't have a From header in your email. A good practice would be to put the following line into your ApplicationMailer:

class ApplicationMailer
  default from: 'noreply@mycustomdomain.com'

  # ...
end

To override this in your inheriting mailers, simply declare the same statement. To override it in individual mail methods, put it into the mail call like so:

def new_message(user, message)
  mail(
    to: user.email,
    subject: "New message from #{message.sender.name}",
    from: message.sender.email
  )
end

Hope that helps

Rails : Authentication and sending confirmation email using Devise , We'll use gmail as a from mail but in next chapter (Rails Heroku Deploy of the most common problems people run into once they have Devise up and running. Devise works with multiple Ruby and Rails versions, and ActiveRecord and Mongoid ORMs, which means you can run the test suite with some modifiers: DEVISE_ORM and BUNDLE_GEMFILE. DEVISE_ORM Since Devise support both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.

In devise.rb config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' had been commented. Config.mailer_sender was never initialized and so always nil even if I set it with default from:

mail confirmable not working in "devise 2.0.4" on rails 3.2.3 · Issue , Hi josevalim I am using rails 3.2.3 and devise 2.0.4 in my rails app. mail confirmable is not By not working you mean you get an error, or the mail is just not sent? :domain => 'gmail.com', #you can also use google.com Also the mail is send by Devise as it is a mail to reset a password. It worked for a time without having to override anything so the problem is somewhere else maybe. – Manspider Jul 11 '17 at 7:50. @LRP it's in devise.rb.

I stumbled upon the same problem. My solution was, I edited config/initializers/devise.rb changed a line from config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' to config.mailer_sender = ENV["default_from_email"]

SMTP configuration for sending rails-devise emails (Page 1 , SMTP configuration for sending rails-devise emails (Page 1) — iRedMail [​IMPORTANT] Related original log or error message is required if you're After Googling, we're posting here because we only find smt gmail config,  I have devise implemented into a rails 3 application. I am trying to get the mailer to work with devise. My current situation is that when I enter an email address which is a default gmail account I have set up.

Sending Emails in Rails with Action Mailer and Gmail, Troubleshooting Email Sending Errors. The above configuration actually didn't work for me at first, due to Google's security features, and I was  Action Mailer Basics. This guide provides you with all you need to get started in sending emails from and to your application, and many internals of Action Mailer. It also covers how to test your mailers. After reading this guide, you will know: How to send email within a Rails application. How to generate and edit an Action Mailer class and

How to Create Events in Google Calendar from Ruby On Rails , Wondering how to create events in Google Calendar from a Ruby on Rails application? First run rails g devise:install, It will prepare your rails app for authentication and adds flash[:error] = 'Your token has been expired. Send Email with Rails by Daniel Kehoe. Last updated 12 December 2012. Sending email from a Ruby on Rails application. How to configure Rails to send email using Gmail or Mandrill accounts. With an introduction comparing Email Service Providers for application transactional email or mailing lists. If You Are New to Rails

Send Email with Rails · RailsApps, How to configure Rails to send email using Gmail or Mandrill accounts. Hundreds of developers use the apps, report problems as they arise, and If you are sending email with Devise, this will enable links in Devise  If you’re new to Rails, see What is Ruby on Rails?, the book Learn Ruby on Rails, and recommendations for a Rails tutorial. Devise Tutorial An in-depth Devise Tutorial is available from the RailsApps project.

Comments
  • this is 10 months old
  • Came here with that error from test suite (rspec): turned out that I didn't add default_options to config/environments/test.rb — fixed it. Thanks! @Manspider, it's now more than 2 years old, but still helpful
  • I do have a default from set to the correct address in my mailer. Also the mail is send by Devise as it is a mail to reset a password. It worked for a time without having to override anything so the problem is somewhere else maybe.
  • @LRP it's in devise.rb. Need something like this: config.mailer_sender = ENV['SMTP_USERNAME']