邮件程序升级后无法正常工作

时间:2015-01-21 11:46:42

标签: ruby-on-rails ruby actionmailer

我们最近将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

1 个答案:

答案 0 :(得分:2)

您在邮件程序操作中错过了对mail的调用。

def my_email
  # ...

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

在你的情况下

def setup_email(...)
  # ...

  mail  to: @recipients,
        from: @from,
        subject: @subject,
end
相关问题