Gareth Burrows
Gareth Burrows

Reputation: 1182

Mailers not working following upgrade

We have recently upgraded form Rails 3.0 to rails 3.2. At the same time we have upgraded from ruby 1.9.3 to Ruby 2.1.5. We are snagging all kinds of things but the one thing that is baffling me is the email, which was working fine before but is now simply not sending. Is there something amiss with the code below?

Controller code

def send_welcome
  UserNotifier.new_user_welcome(user).deliver
  ...
end

Notifier code

class EmployeeNotifier < ActionMailer::Base

def setup_email(to, subject, from = Saas::Config.from_email)
  @sent_on = Time.zone.now
  @subject = subject
  @recipients = to.respond_to?(:email) ? to.email : to
  @from = from.respond_to?(:email) ? from.email : from
end

def new_user_welcome(user)
  @user = user
  setup_email(user.email,"Welcome!")
end

Upvotes: 0

Views: 36

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176552

You are missing the call to mail inside the mailer action.

def my_email
  # ...

  mail  to: "recipient",
        subject: "..."
end

In your case

def setup_email(...)
  # ...

  mail  to: @recipients,
        from: @from,
        subject: @subject,
end

Upvotes: 2

Related Questions