Ruby on rails Rails:向多个收件人发送邮件(奇怪的格式)
我想向多个收件人发送邮件,以下是我的资料:Ruby on rails Rails:向多个收件人发送邮件(奇怪的格式),ruby-on-rails,email,Ruby On Rails,Email,我想向多个收件人发送邮件,以下是我的资料: def teaser(customer) @customer = customer mail(to: customer.shop.email, subject: "Here's an interesting stat") mail(to: "admin@mysite.co", subject: "#{customer.shop.email} had an interesting stat") end 但是我现在收到的电子邮
def teaser(customer)
@customer = customer
mail(to: customer.shop.email, subject: "Here's an interesting stat")
mail(to: "admin@mysite.co", subject: "#{customer.shop.email} had an interesting stat")
end
但是我现在收到的电子邮件admin@mysite.co有非常奇怪的格式。电子邮件内容以不同格式重复3次,首先是:
----==_mimepart_563ad1e4c3af4_9d3f90c47cfe7c324dc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding
我做错了什么?如果您的客户在阵列中
def teaser(customers)
customers.each do |customer|
mail(to: customer.shop.email, subject: "Here's an interesting stat")
mail(to: "admin@mysite.co", subject: "#{customer.shop.email} had an interesting stat")
end
end
当我尝试使用Action Mailer向多个收件人发送多部分电子邮件时,邮件正文中的MIME类型信息也遇到了同样的问题。我最初与客户有一个ActiveRecord关系,然后试图通过他们一次发送一封电子邮件
customers = User.where(access: "customer")
customers.each do |customer|
mail to: customer.email, subject: "email subject test"
end
但是我不得不将一个数组或逗号分隔的列表传递给邮件发送程序,从而解决了邮件正文中MIME类型信息的问题
customers = User.where(access: "customer")
customers_emails = customers.map {|c| c.email}
mail(to: customers_emails, subject: 'testing')
不是我想解决的问题。我的问题是,我的代码发送的电子邮件格式非常奇怪,正文中包含MIME类型