2

In rails 4, after reading the documentation, I can see how to get the "from" field : @email.from[:email] from the Email object, but I cannot find how to get the bcc field.

I am trying to get the bcc field of emails I am catching with the sendgrid Inbound Parse service. Any ideas how to do that?

Thrabbit
  • 193
  • 2
  • 12

1 Answers1

3

You can't. BCC headers are removed by the SMTP server at the time that you send the message. Each recipient gets their own envelope at that point. If this header were included in the delivered message, then anyone could see the list of blind recipients.

bwest
  • 9,182
  • 3
  • 28
  • 58
  • Suppose user1@test.com was put down as unique bcc, and my webhook captures that email because it is send to the domain which I have set up with griddler-sendgrid. How can I extract "user1@test.com" ? it will not be in the "to" field, I can see it will be in the raw_header, but is there a short cut to get that value? thx – Thrabbit Oct 27 '16 at 12:14
  • That address should be the envelope to, not the header to. Does griddler give you an envelope hash, maybe something like `envelope["to"]`? – bwest Oct 27 '16 at 15:38
  • tried to get the envelope but @email.envelope gives error : Undefined method 'envelope' for #> – Thrabbit Oct 30 '16 at 23:51
  • hmm... I don't have direct griddler experience or a Rails env to test with, but this looks like the relevant part of the adapter to dig into... https://github.com/thoughtbot/griddler-sendgrid/blob/master/lib/griddler/sendgrid/adapter.rb#L47-L56 – bwest Oct 31 '16 at 13:43