0
我想在用戶確認後發送電子郵件給事件管理員。Rails:設計:確認後錯誤
參見:Rails: Devise: Sending an email after user comfirms registration
我寫了一個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'
任何想法?
編輯:
的解決方案是同時移動:以和:從郵件nethod內
我仍然得到同樣的錯誤。該文檔說:可以在smtp_settings hassh – EastsideDeveloper
這些文檔在哪裏?關於允許:在smtp_settings哈希中,我沒有看到任何[這裏](http://api.rubyonrails.org/classes/ActionMailer/Base.html#label-Configuration+options)。 – flynfish
對不起。不是文檔,而是StackOverflow上的QA會話。事實證明,解決方案是在郵件方法內移動To和From – EastsideDeveloper