[英]How to send the list of receivers of a actionmailer method to a different email?
以下是我的ActionMailer方法,用于向收件人发送一些批量电子邮件。
def mail_to
@default_email = "user@gmail.com"
@receivers #contains the array of all the receivers
mail(bcc: @receiver, to: @default_mail) if @receiver.present?
end
一切正常。 但现在我想送@default_email
接收器的所有列表中@receivers
可变文本或列表的形式。 有没有一种方法可以在同一方法中实现这一目标而不必为此创建另一个actionmailer方法?
您可以在模板中添加@receivers变量并添加条件,以便只有@default_email可以看到@receiver变量。 例如
<% if user.email == "user@gmail.com" %>
<% @receivers.each do |r| %>
<%= r.email %>
<%end%>
<% end %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.