【问题标题】:Adding a BCC to a multipart ActionMailer action makes it not send as multipart, but garbage将密件抄送添加到多部分 ActionMailer 操作使其不会作为多部分发送,而是作为垃圾发送
【发布时间】:2011-01-28 02:35:38
【问题描述】:

我的代码如下所示:

def coupon_available_notice(order, bcc=false)
  # [...]
  headers = {
    :to       => @user.email,
    :from     => "info@domain.com",
    :subject  => subject
  }
  headers[:bcc] = "remail@domain.com" if bcc == true
  mail(headers)
end

当密件抄送为真时 - 消息以纯文本形式发送,所有多部分边界和代码在电子邮件中显示为纯文本垃圾。当 bcc 为 false 时,它​​可以正常发送。

为什么会这样??

【问题讨论】:

    标签: email ruby-on-rails-3 actionmailer multipart


    【解决方案1】:

    事实证明这是我需要的:

    def coupon_available_notice(order, bcc=false)
      # [...]
      h = {
        :to       => @user.email,
        :from     => "info@domain.com",
        :subject  => subject
      }
      h[:bcc] = "remail@domain.com" if bcc == true
      mail(h)
    end
    

    headers 是 ActionMailer 操作中的保留关键字,因此它显然是以某种非标准方式或其他方式设置密件抄送。只要把它改成'h',问题就消失了!

    愚蠢的错误?也许。但我敢打赌其他人也会做同样的事情;)

    【讨论】:

      猜你喜欢
      • 2012-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-03
      • 2018-07-27
      相关资源
      最近更新 更多