简体   繁体   English

Amazon SES:如何向所有用户发送HTML邮件

[英]Amazon SES: How to send HTML mail to all users

I want to send all users (<200) on the rails application. 我想在rails应用程序上发送所有用户(<200)。 The mail server is Amazon SES. 邮件服务器是Amazon SES。 If the lists were over 50, we have to divide email transactions. 如果列表超过50,我们必须划分电子邮件交易。

So I coded like below: 所以我编码如下:

class NewsMailer < ApplicationMailer
  def all_notify(news)
    @news = news
    @users = User.where(is_news: true)

    @users.each do |user|
      mail(
        subject: @news.title,
        to: user.email,
      )
    end
  end
end

Although email has been sent, but html was collapsed like this. 虽然已经发送了电子邮件,但html却像这样崩溃了。

When I try to send to one user. 当我尝试发送给一个用户时。 It doesn't occur the problem. 它不会出现问题。 But when using each causes the problem... 但是each使用时each导致问题......

Do you have any ideas? 你有什么想法?

  @users.each do |user|
    NewsMailer.all_notify(@news, user).deliver
  end

I could do it by writing each on the controller. 我可以通过在控制器上写each来做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM