DEV Community

Discussion on: Using Mail Interceptors in Rails

Collapse
 
drbragg profile image
Drew Bragg

Yup, I called that out after the example

Aside from the slight changes to how we handle CC's (which the team is happy with) this will do the same thing as the original code

We actually ended up missing the additional CC emails so that block has since been replaced with:

if mail.cc.present?
  mail.cc.each do |recipient|
    RawMailer.raw(
      "from" => mail.from,
      "recipients" => recipient,
      "subject" => "CCed version of: #{original_subject}",
      "plain_text_content" => mail.parts.first.body.to_s,
      "html_content" => mail.parts.last.body.to_s
    ).deliver_later
  end
  mail.cc = []
end
Enter fullscreen mode Exit fullscreen mode

So now it does basically the same thing.