我需要发送大量电子邮件,我将用于背景作业延迟作业,并且必须以 3 种语言(de、en、re)创建电子邮件,如何缓存视图以便不必每次都创建我正在调用邮件方法。
问问题
397 次
1 回答
1
The deliver method is the one that sends the email, so you can do this:
def send_emails
# You can set here the email with attachments and all stuff
mail = MyMailer.send_message("demo@example.com")
body = mail.html_part.body
User.all.each do |u|
mail.to = u.email
mail.html_part.body = body.gsub(/user_id/, u.id)
mail.deliver
end
end
Of course it's better if you set this method for background processing.
于 2012-04-05T06:05:04.860 回答