作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试根据数据库中的 bool 值发送多封电子邮件。该应用程序是一个简单的调度应用程序,用户可以将他们的轮类标记为“replacement_needed”,这应该向所有请求接收这些电子邮件的用户发送电子邮件。问题是,它似乎只发送一封电子邮件。这是我当前的代码:
def request_replacement(shift)
@shift = shift
@user = shift.user
@recipients = User.where(:replacement_emails => true).all
@url = root_url
@recipients.each do |r|
@name = r.fname
mail(:to => r.email,
:subject => "A replacement clerk has been requested")
end
end
最佳答案
在 Rails 指南(Action Mailer 基础知识)中,它对多封电子邮件说了以下内容:
The list of emails can be an array of email addresses or a single string with the addresses separated by commas.
因此 "test1@gmail.com, test1@gmail.com"
和 ["test1@gmail.com", "test1@gmail.com"]
应该可以。
查看更多信息:http://guides.rubyonrails.org/action_mailer_basics.html
关于ruby-on-rails-3 - 使用 ActionMailer 在 Rails 中发送给多个收件人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7437270/
我是一名优秀的程序员,十分优秀!