0
我已添加以下代碼。但無法發送批量郵件。延遲作業不在軌道中工作4
的Gemfile
gem 'delayed_job_active_record'
控制器
def send_news_letter
@emails = Array.new
if params[:newsletter].present?
@newsletter = Newsletter.find(params[:newsletter].keys).first
end
if params[:students].present?
@emails = @emails + Student.all
#raise @emails.inspect
end
if params[:teachers].present?
@emails = @emails +Teacher.all
end
if params[:parents].present?
@emails = @emails + Parent.all
end
UserMailer.delay.send_multiple_email(@emails,@newsletter)
redirect_to newsletters_url, :notice => "Delivering Newsletter"
end
郵件
class UserMailer < ActionMailer::Base
default from: "[email protected]"
def send_multiple_email(emails,newsletter)
@emails = emails
#raise @emails.inspect
@newsletter = newsletter
mail(:to => @emails.map(&:email), subject: "Deliver")
end
end
其實它重定向通訊的索引頁。但它不會發送郵件..