# controller
User.all.pluck(:email).each do |email|
NoticeMailer.alarm_email(email).deliver
end
# NoticeMailer
def alarm_email(email)
# Эти настройки в конфиг нужно вынести
delivery_options = {
address: "smtp.mail.ru",
port: 465,
domain: "mail.ru",
authentication: :login,
tls: true,
user_name: "login@mail.ru",
password: "password",
enable_starttls_auto: true
}
mail to: email, subject: "Subject", delivery_method_options: delivery_options
end
И настоятельно рекомендую
https://github.com/collectiveidea/delayed_job или аналоги для таких задач.