邮件程序在升级后不工作

Mailers not working following upgrade

我们最近将 Rails 3.0 升级到 rails 3.2。同时我们从ruby 1.9.3升级到Ruby 2.1.5。我们遇到了各种各样的事情,但让我感到困惑的一件事是电子邮件,它以前工作正常,但现在根本无法发送。下面的代码有什么问题吗?

控制器代码

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

通知代码

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

您在邮件操作中缺少对 mail 的调用。

def my_email
  # ...

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

你的情况

def setup_email(...)
  # ...

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