wingrunr21 / griddler-mandrill

Mandrill adapter for Griddler
MIT License
16 stars 49 forks source link

Unable to access email headers #16

Closed jakeprime closed 9 years ago

jakeprime commented 9 years ago

I am not able to see any headers for received emails. @email.headers returns {} and @email.raw_headers returns an empty string.

I am trying to get to the Date property. It is possible (e.g. if my app is temporarily down) for an email to be received at a different time to when it was sent, and if there are multiple they can be received out of order. I would like to have the sent time so I can have a correct timeline of emails.

wingrunr21 commented 9 years ago

A few things:

1) I definitely need more information to debug this. If you can share a sanitized payload from Mandrill that'd be very helpful 2) This adapter doesn't do the header extraction. The base griddler gem does that. So, there's either a bug there or something in Mandrill's response is not playing nice with griddler. If that's the case, we can probably normalize/fix that prior to sending it on to griddler for parsing.

Also, this may be related to #12, in which case it is definitely a problem on the griddler side that needs to be fixed first.

jakeprime commented 9 years ago

Sure, this is what I get from the console:

Processing by Griddler::EmailsController#create as */*
  Parameters: {"mandrill_events"=>"[{\"event\":\"inbound\",\"ts\":1430918199,\"msg\":{\"raw_msg\":\"Received: from mail-oi0-f51.google.com (unknown [209.85.218.51])\\n\\tby ip-10-31-192-99 (Postfix) with ESMTPS id 034B24006BB\\n\\tfor <jake@example.com>; Wed,  6 May 2015 13:16:39 +0000 (UTC)\\nReceived: by oica37 with SMTP id a37so6919607oic.0\\n        for <jake@example.com>; Wed, 06 May 2015 06:16:38 -0700 (PDT)\\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed\\/relaxed;\\n        d=gmail.com; s=20120113;\\n        h=mime-version:date:message-id:subject:from:to:content-type;\\n        bh=FmktgxXpTzPsPpBkurMEZep3daD2i9HZ9isDqp5\\/plA=;\\n        b=iXH2yGfHjfz97UCziGYxgj6fWex+qd0Xtt\\/7OVVXNha4OEjmJjLKIOkq6bP63ACbcB\\n         zOKTWh1trTfEbva3g904zrdNh6YQzMDmmq8ExrEbGKDJ208wk\\/l9hXlGwbKLhYEFtHjO\\n         d6kHXr9FEcMBWekcl59n3EjU8b+O1mq2s\\/1CXL0u60\\/6n9q0EVLjjWoKEZ5MO4xehHc3\\n         7AosisZIeiaH9F+Bnp8mlt0sTfjDAVLHz3zlznLHKu+QsTkOa+8P6tw5Z8cxVttftpM4\\n         +iEvYuZlJroq1J5cGqKNvg3HiMt3myMkS2qYo2iJSnPbItdanoAif8lbVY++tMm0wb8y\\n         DqvA==\\nMIME-Version: 1.0\\nX-Received: by 10.202.200.209 with SMTP id y200mr8347392oif.20.1430918198404;\\n Wed, 06 May 2015 06:16:38 -0700 (PDT)\\nReceived: by 10.202.58.132 with HTTP; Wed, 6 May 2015 06:16:38 -0700 (PDT)\\nDate: Wed, 6 May 2015 14:16:38 +0100\\nMessage-ID: <CAG7Hn1DJO1q1SH_t43C5FsyjXjfFnbk1NWuukpr1EVWQL2LuUw@mail.gmail.com>\\nSubject: Check the status on this one\\nFrom: Jake <jake@gmail.com>\\nTo: jake@example.com\\nContent-Type: multipart\\/alternative; boundary=001a11c1765aeb2c3f0515699a4c\\n\\n--001a11c1765aeb2c3f0515699a4c\\nContent-Type: text\\/plain; charset=UTF-8\\n\\n\\n\\n--001a11c1765aeb2c3f0515699a4c\\nContent-Type: text\\/html; charset=UTF-8\\n\\n<div dir=\\\"ltr\\\"><br><\\/div>\\n\\n--001a11c1765aeb2c3f0515699a4c--\",\"headers\":{\"Received\":[\"from mail-oi0-f51.google.com (unknown [209.85.218.51]) by ip-10-31-192-99 (Postfix) with ESMTPS id 034B24006BB for <jake@example.com>; Wed,  6 May 2015 13:16:39 +0000 (UTC)\",\"by oica37 with SMTP id a37so6919607oic.0 for <jake@example.com>; Wed, 06 May 2015 06:16:38 -0700 (PDT)\",\"by 10.202.58.132 with HTTP; Wed, 6 May 2015 06:16:38 -0700 (PDT)\"],\"Dkim-Signature\":\"v=1; a=rsa-sha256; c=relaxed\\/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=FmktgxXpTzPsPpBkurMEZep3daD2i9HZ9isDqp5\\/plA=; b=iXH2yGfHjfz97UCziGYxgj6fWex+qd0Xtt\\/7OVVXNha4OEjmJjLKIOkq6bP63ACbcB zOKTWh1trTfEbva3g904zrdNh6YQzMDmmq8ExrEbGKDJ208wk\\/l9hXlGwbKLhYEFtHjO d6kHXr9FEcMBWekcl59n3EjU8b+O1mq2s\\/1CXL0u60\\/6n9q0EVLjjWoKEZ5MO4xehHc3 7AosisZIeiaH9F+Bnp8mlt0sTfjDAVLHz3zlznLHKu+QsTkOa+8P6tw5Z8cxVttftpM4 +iEvYuZlJroq1J5cGqKNvg3HiMt3myMkS2qYo2iJSnPbItdanoAif8lbVY++tMm0wb8y DqvA==\",\"Mime-Version\":\"1.0\",\"X-Received\":\"by 10.202.200.209 with SMTP id y200mr8347392oif.20.1430918198404; Wed, 06 May 2015 06:16:38 -0700 (PDT)\",\"Date\":\"Wed, 6 May 2015 14:16:38 +0100\",\"Message-Id\":\"<CAG7Hn1DJO1q1SH_t43C5FsyjXjfFnbk1NWuukpr1EVWQL2LuUw@mail.gmail.com>\",\"Subject\":\"Check the status on this one\",\"From\":\"Jake <jake@gmail.com>\",\"To\":\"jake@example.com\",\"Content-Type\":\"multipart\\/alternative; boundary=001a11c1765aeb2c3f0515699a4c\"},\"text\":\"\\n\\n\",\"text_flowed\":false,\"html\":\"<div dir=\\\"ltr\\\"><br><\\/div>\\n\\n\",\"from_email\":\"jake@gmail.com\",\"from_name\":\"Jake\",\"to\":[[\"jake@example.com\",null]],\"subject\":\"Check the status on this one\",\"spf\":{\"result\":\"pass\",\"detail\":\"sender SPF authorized\"},\"spam_report\":{\"score\":0.5,\"matched_rules\":[{\"name\":\"RCVD_IN_DNSWL_LOW\",\"score\":-0.7,\"description\":\"RBL: Sender listed at http:\\/\\/www.dnswl.org\\/, low\"},{\"name\":null,\"score\":0,\"description\":null},{\"name\":\"listed\",\"score\":0,\"description\":\"in list.dnswl.org]\"},{\"name\":\"FREEMAIL_FROM\",\"score\":0,\"description\":\"Sender email is commonly abused enduser mail provider\"},{\"name\":\"HTML_MESSAGE\",\"score\":0,\"description\":\"BODY: HTML included in message\"},{\"name\":\"DKIM_VALID_AU\",\"score\":-0.1,\"description\":\"Message has a valid DKIM or DK signature from author's\"},{\"name\":\"DKIM_SIGNED\",\"score\":0.1,\"description\":\"Message has a DKIM or DK signature, not necessarily valid\"},{\"name\":\"DKIM_VALID\",\"score\":-0.1,\"description\":\"Message has at least one valid DKIM or DK signature\"},{\"name\":\"RDNS_NONE\",\"score\":1.3,\"description\":\"Delivered to internal network by a host with no rDNS\"}]},\"dkim\":{\"signed\":true,\"valid\":true},\"email\":\"jake@example.com\",\"tags\":[],\"sender\":null,\"template\":null}}]"}
wingrunr21 commented 9 years ago

@jakeprime please try release v1.1.0 as this includes some fixes around headers

wingrunr21 commented 9 years ago

I am closing this issue as I believe v1.1.1 resolves this

jakeprime commented 9 years ago

Sorry for delay, I've been working on other projects. The latest version works just great, thank you.