ActionMailerを使えば、動的にメールを生成できます。
Ruby
1# app/mailers/user_mailer.rb
2class UserMailer < ActionMailer::Base
3 def all_notify(users, title, content)
4 mail from: 'mail_sender@address.jp'
5 mail to: users.map{|u| u.mail}
6 mail subject: title
7 @content = content
8 end
9end
10
11# app/view/user_mailer/all_notify.txt.erb
12
13こんにちは
14ここから本文--------------
15#{@content}
16---------------------ここまで
17
18# app/controllers/user_controller.rb メールを送信するコントローラ
19
20# 前略
21 def send_to_all
22 title = params[:title]
23 content = params[:content]
24 users = User.all
25 UserMailer.all_notify(users, title, content).deliver
26 end
27# 後略
こんな感じでしょうか。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。