Save 36% for Black Friday! Learn more

All threads / Action mailer rails 6

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Action mailer rails 6

Pratima Singh asked in Rails

Hey Chris,

cannot send email from console using UserMailer.welcome_email.perform_now, geting this error

Traceback (most recent call last):
        1: from (irb):3
NameError (uninitialized constant UserMailer
irb(main):004:0> 

why is it saying (uninitialized constant UserMailer)

Is the filename correct for that file? Maybe a typo somewhere? it's usually something as simple as that.

cannot send email from console using in rails 6

EmailMailer.welcome.perform_now
Traceback (most recent call last):
2: from (irb):2
1: from (irb):2:in `rescue in irb_binding'
NameError (uninitialized constant EmailMailer)

my EmailMailer

class EmailMailer < ApplicationMailer

def welcome
@greeting = "Hi"

mail to:  my_email_address

end
end

I'm having the same problem in Rails 6.0.2. After generating a mailer UserMailer, running it in console results the following:

irb(main):001:0> UserMailer
Traceback (most recent call last):
        1: from (irb):1
NameError (uninitialized constant UserMailer)

I've checked the file names and everything is named correction (user_mailer.rb and the class is UserMailer).

Oddly enough, running ApplicationMailer in the console is recognised.

irb(main):003:0> ApplicationMailer
=> ApplicationMailer

Has something changed since rails 5 where you can't run mailer actions from the console?

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 39,609+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.