Send email to all users in rails

前端 未结 1 991
星月不相逢
星月不相逢 2021-01-07 01:57

I am trying to create a method that, when called send a email to all users.

My ultimate goal is to call this method via a scheduler (i already got the scheduler work

相关标签:
1条回答
  • 2021-01-07 02:21

    For each call to the mailer method one email is sent

    in scheduled worker

    def calling_method
       @users.each do |user|
         send_digest(user.email, user.name)
       end
    end
    

    in user mailer

    def send_digest(user_email, user_name)
       mail(to: user_email, subject: user_name)
    end
    
    0 讨论(0)
提交回复
热议问题