我有一張電子郵件表。我需要每個用戶都收到電子郵件。需要發送電子郵件的幫助
所以我提出:
script/generate mailer Notifier
下一步。
class Notifier < ActionMailer::Base
def newgrants_notification(respondent)
recipients user.email
from "[email protected]"
subject "Hi!"
body (:respondent => respondent)
end
end
在app/views/notifier/newgrants_notification.erb
寫道:Hello!
,這我的控制器,其中i創建問題
@question = Question.create(:text => params[:question][:text], :security => rand(888).to_i)
if success = @question.save
respondents = Respondent.find(:all)
respondents.each do |res|
Inquiry.create(:question_id=>@question.id.to_i, :respondent_id=>res.id.to_i)
Notifier.newgrants_notification(respondents).deliver #this is right??
end
我做了什麼錯誤?消息不會來;(
謝謝,現在我明白了,只有當項目處於生產模式時,我纔會收到電子郵件? – 2011-04-11 07:35:13
收件人user.email也檢查此 – Bijendra 2011-04-11 07:35:15
http://stackoverflow.com/questions/5485348/how-does-actionmailer-work/5485972#5485972 – Bijendra 2011-04-11 07:43:00