gpt4 book ai didi

ruby-on-rails-3 - 使用 ActionMailer 在 Rails 中发送给多个收件人

转载 作者:行者123 更新时间:2023-12-03 06:06:10 25 4
gpt4 key购买 nike

我正在尝试根据数据库中的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com