导轨:设计:确认后错误



用户确认后,我正在尝试向活动管理员发送电子邮件。

请参阅:Rails:设计:在用户确认注册后发送电子邮件

我编写了一个 EventMailer 类,如下所示:

class EventMailer < ActionMailer::Base
  @user = User
  @host_name = "localhost:3000" if Rails.env.development?
  @host_name = "test.com" if Rails.env.test?
  @host_name = "production.com" if Rails.env.production?
 def self.send_email_to_admin
   @@smtp_settings = { #override default smtp settings since I'm using a difference sender
     :address => "smtp.gmail.com",
     :port => 587,
     :domain => @host_name,
     :authentication => "plain",
     :enable_starttls_auto_=> true,
     :user_name => ENV["ORG_FROM"],
     :password => ENV["ORG_FROM_PWD"],
     :to => ADMIN_RECIPIENTS
     #ADMIN_RECIPIENTS is defined elsewhere
   }
   mail(:subject => "Invite request received from " + @user.first.to_s + " " + @user.last.to_s)
 end
end

当用户注册时,他们会收到一个注册链接。当他们单击该链接时,他们会收到以下错误消息:

undefined method `mail' for EventMailer:Class
app/mailers/event_mailer.rb:20:in `send_email_to_admin'
app/controllers/confirmations_controller.rb:11:in `show'

有什么想法吗?

编辑:

解决方案是将 :to 和 :从邮件网络内部移动

尝试将:to => DENT_ADMIN_RECIPIENTS移动到 mail 方法中:

mail(:to => DENT_ADMIN_RECIPIENTS, :subject => "Invite request received from " + @user.first.to_s + " " + @user.last.to_s)

相关内容

  • 没有找到相关文章

最新更新