Question

I'm trying to send an email to myself every time any user creates and saves a new record. I currently have this in the part of my controller that saves new records:

UserMailer.notification_email().deliver

And this in my user mailer:

class UserMailer < ActionMailer::Base
  default from: "from@example.com"

  def notification_email()



    mail(:to => "admin@example.co.uk",
         :subject => "Test")
  end

end

I'm aware it should probably pass some parameters I'm just not sure what, plus all the examples I can find send out emails to each user rather than a static email address.

Was it helpful?

Solution

Have you set smtp settings in environment? Something like this:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  # your settings
}

OTHER TIPS

Have a look at this RailsCast http://railscasts.com/episodes/206-action-mailer-in-rails-3. It also provides insights on how to use action mailer in development/production.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top