Ruby Rails,发送所有外发电子邮件的副本

Ruby on Rails, Send a copy of all outgoing emails

我想保存从 RoR 发送的每封电子邮件的副本。 有没有办法让 ActionMailer 将每封电子邮件的副本发送到特定地址(可能是密件抄送)

Background: I have been doing this using Mandrillapp automatically using "send a copy of every email to this address" from their settings page. I am now moving from Mandrill to Amazon SES and would like to continue using a similar functionality.

您应该可以在邮件方法上设置 bcchttp://api.rubyonrails.org/classes/ActionMailer/Base.html

您也可以通过另一个 mail() 电话发送相同电子邮件内容的副本。

你应该试试这个 -

mail(to: "a@mail.com", subject: "Test",
     bcc: "b@mail.com",
     cc: "c@mail.com")

您可以使用观察者:

class EmailDeliveryObserver
  def self.delivered_email(message)
    EmailDelivery.log(message)
  end
end
Rails.application.configure do
  config.action_mailer.observers = %w[EmailDeliveryObserver]
end

发件人:https://guides.rubyonrails.org/action_mailer_basics.html#observing-emails