Rails:向多个收件人发送邮件(奇怪的格式化)

时间:2015-11-08 19:34:03

标签: 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

但是我在admin@mysite.co收到的电子邮件格式非常奇怪。电子邮件内容以不同格式重复3次,从以下开始:

----==_mimepart_563ad1e4c3af4_9d3f90c47cfe7c324dc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding

我做错了什么?

2 个答案:

答案 0 :(得分:0)

如果您的客户在阵列中

class RollDice
{

   const int EYE = 1;
   const int BOX = 6;

    public int RollDice1(ref int dieValue1)
    {
        Random randomNums = new Random();

         dieValue1 = randomNums.Next(1, 7);

        return dieValue1;

    }

    public int RollDice2(ref int dieValue2)
    {
        Random randomNums = new Random();

         dieValue2 = randomNums.Next(1, 7);

        return dieValue2;

    }






}

答案 1 :(得分:0)

当尝试使用Action Mailer向多个收件人发送多部分电子邮件时,电子邮件正文中的MIME类型信息出现相同的问题。我最初是与客户建立ActiveRecord关系,然后尝试遍历他们,一次向他们发送电子邮件。

int l = 4
int r = 2
int k = 2
int[] temp = new int[1+r-l];
for(int j = l-1; j < r; j++) {
    temp[j-l+1] = arr[j];
}
Arrays.sort(temp);
System.out.println(temp[temp.length-k]);

但是我不得不将数组或逗号分隔的列表传递给邮件程序,这解决了电子邮件正文中的MIME类型信息的问题。

customers = User.where(access: "customer") 

   customers.each do |customer|
     mail to: customer.email, subject: "email subject test"  
   end