thoughtbot / griddler

Simplify receiving email in Rails (deprecated)
http://griddler.io/
MIT License
1.38k stars 199 forks source link

Processor method not running for some emails.. #236

Closed echan00 closed 8 years ago

echan00 commented 8 years ago

From the logs, I can see that the incoming email is being received and a post request is being made along with the params containing the email contents.

Only for some emails, the processor method is being run (I am using the default names 'EmailProcess' class and 'Process' method). This seems to work fine when the incoming email I am testing with is a simple email directed to the mailbox.

In the case where the processor method isn't run, it is usually when I am forwarding an email I received to the incoming mailbox. In this case, nothing happens after the post request.

I've been trying to debug this issue but to no avail. Any suggestions for why I'm running into this problem?

xinlangzi commented 8 years ago

@echan00

I have same experience for mandrill service:

The process does not run for following params:

{"mandrill_events"=>"[{\"event\":\"inbound\",\"ts\":1448444501,\"msg\":{\"raw_msg\":\"Received: from qproxy2.mail.unifiedlayer.com (unknown [69.89.16.161])\n\tby ip-10-212-6-2 (Postfix) with SMTP id 8413E380BA2\n\tfor jordan@test.com; Wed, 25 Nov 2015 09:41:38 +0000 (UTC)\nReceived: (qmail 25083 invoked by uid 0); 25 Nov 2015 09:41:37 -0000\nReceived: from unknown (HELO cmgw4) (10.0.90.85)\n by qproxy2.mail.unifiedlayer.com with SMTP; 25 Nov 2015 09:41:37 -0000\nReceived: from host113.hostmonster.com ([74.220.207.113])\n\tby cmgw4 with \n\tid llhW1r0082TL29E01lhZ1X; Wed, 25 Nov 2015 02:41:37 -0700\nX-Authority-Analysis: v=2.1 cv=IekUBwaa c=1 sm=1 tr=0\n a=d7rUCv23sIuWlEixWzccFw==:117 a=d7rUCv23sIuWlEixWzccFw==:17 a=DsvgjBjRAAAA:8\n a=f5113yIGAAAA:8 a=nTg3QbKWAAAA:8 a=2m6t4_WUAAAA:8 a=kj9zAlcOel0A:10\n a=BqgCfznX7MUA:10 a=x25COIZeJJIA:10 a=qtqOOiqGOCEA:10\n a=--nS0x-IEJzKwQJoCuMA:9 a=CjuIK1q8ugA:10\nReceived: from [42.120.134.154](port=1141 helo=out1134-154.mail.aliyun.com)\n\tby host113.hostmonster.com with esmtp (Exim 4.84)\n\t(envelope-from jordan@example.com)\n\tid 1a1WZt-00082D-5l\n\tfor jordan@journeyinstruments.com; Wed, 25 Nov 2015 02:41:29 -0700\nX-Alimail-AntiSpam:AC=CONTINUE;BC=0.4886912|-1;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03299;MF=jordan@example.com;NM=1;PH=DS;RN=2;RT=2;SR=0;TI=SMTPD----4GKrv3Q;\nReceived: from 192.168.100.163(mailfrom:jordan@example.com ip:63.251.90.2)\n by smtp.aliyun-inc.com(10.194.100.216);\n Wed, 25 Nov 2015 17:41:24 +0800\nFrom: Aliyun jordan@example.com\nContent-Type: text\/plain; charset=us-ascii\nContent-Transfer-Encoding: 7bit\nSubject: Forward.....\nDate: Wed, 25 Nov 2015 17:41:18 +0800\nMessage-Id: EF5B46E4-E8DA-4236-B045-B7E608A9AB24@example.com\nCc: Aliyun jordan@example.com\nTo: Journey jordan@journeyinstruments.com\nMime-Version: 1.0 (Mac OS X Mail 9.0 \(3094\))\nX-Mailer: Apple Mail (2.3094)\nX-Identified-User: {0000:host113.hostmonster.com:local:local} {sentby:Delivered locally}\n\nForward.....\",\"headers\":{\"Received\":[\"from qproxy2.mail.unifiedlayer.com (unknown [69.89.16.161]) by ip-10-212-6-2 (Postfix) with SMTP id 8413E380BA2 for jordan@test.com; Wed, 25 Nov 2015 09:41:38 +0000 (UTC)\",\"(qmail 25083 invoked by uid 0); 25 Nov 2015 09:41:37 -0000\",\"from unknown (HELO cmgw4) (10.0.90.85) by qproxy2.mail.unifiedlayer.com with SMTP; 25 Nov 2015 09:41:37 -0000\",\"from host113.hostmonster.com ([74.220.207.113]) by cmgw4 with id llhW1r0082TL29E01lhZ1X; Wed, 25 Nov 2015 02:41:37 -0700\",\"from [42.120.134.154](port=1141 helo=out1134-154.mail.aliyun.com) by host113.hostmonster.com with esmtp (Exim 4.84) (envelope-from jordan@example.com) id 1a1WZt-00082D-5l for jordan@journeyinstruments.com; Wed, 25 Nov 2015 02:41:29 -0700\",\"from 192.168.100.163(mailfrom:jordan@example.com ip:63.251.90.2) by smtp.aliyun-inc.com(10.194.100.216); Wed, 25 Nov 2015 17:41:24 +0800\"],\"X-Authority-Analysis\":\"v=2.1 cv=IekUBwaa c=1 sm=1 tr=0 a=d7rUCv23sIuWlEixWzccFw==:117 a=d7rUCv23sIuWlEixWzccFw==:17 a=DsvgjBjRAAAA:8 a=f5113yIGAAAA:8 a=nTg3QbKWAAAA:8 a=2m6t4_WUAAAA:8 a=kj9zAlcOel0A:10 a=BqgCfznX7MUA:10 a=x25COIZeJJIA:10 a=qtqOOiqGOCEA:10 a=--nS0x-IEJzKwQJoCuMA:9 a=CjuIK1q8ugA:10\",\"X-Alimail-Antispam\":\"AC=CONTINUE;BC=0.4886912|-1;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03299;MF=jordan@example.com;NM=1;PH=DS;RN=2;RT=2;SR=0;TI=SMTPD----4GKrv3Q;\",\"From\":\"Aliyun jordan@example.com\",\"Content-Type\":\"text\/plain; charset=us-ascii\",\"Content-Transfer-Encoding\":\"7bit\",\"Subject\":\"Forward.....\",\"Date\":\"Wed, 25 Nov 2015 17:41:18 +0800\",\"Message-Id\":\"EF5B46E4-E8DA-4236-B045-B7E608A9AB24@example.com\",\"Cc\":\"Aliyun jordan@example.com\",\"To\":\"Journey jordan@journeyinstruments.com\",\"Mime-Version\":\"1.0 (Mac OS X Mail 9.0 \(3094\))\",\"X-Mailer\":\"Apple Mail (2.3094)\",\"X-Identified-User\":\"{0000:host113.hostmonster.com:local:local} {sentby:Delivered locally}\"},\"text\":\"Forward.....\",\"text_flowed\":false,\"from_email\":\"jordan@example.com\",\"from_name\":\"Aliyun\",\"to\":[[\"jordan@journeyinstruments.com\",\"Journey\"]],\"cc\":[[\"jordan@example.com\",\"Aliyun\"]],\"subject\":\"Forward.....\",\"spf\":{\"result\":\"softfail\",\"detail\":\"domain owner discourages use of this host\"},\"spam_report\":{\"score\":1.3,\"matched_rules\":[{\"name\":\"RCVD_IN_DNSWL_NONE\",\"score\":-0,\"description\":\"RBL: Sender listed at http:\/\/www.dnswl.org\/, no\"},{\"name\":null,\"score\":0,\"description\":null},{\"name\":\"listed\",\"score\":0,\"description\":\"in list.dnswl.org]\"},{\"name\":\"RDNS_NONE\",\"score\":1.3,\"description\":\"Delivered to internal network by a host with no rDNS\"},{\"name\":\"TVD_SPACE_RATIO\",\"score\":0,\"description\":\"TVD_SPACE_RATIO\"},{\"name\":\"UNPARSEABLE_RELAY\",\"score\":0,\"description\":\"Informational: message has unparseable relay lines\"}]},\"dkim\":{\"signed\":false,\"valid\":false},\"email\":\"jordan@test.com\",\"tags\":[],\"sender\":null,\"template\":null}}]"}

But the process DOES run for following params:

{"mandrill_events"=>"[{\"event\":\"inbound\",\"ts\":1448444600,\"msg\":{\"rawmsg\":\"Received: from out1134-137.mail.aliyun.com (unknown [42.120.134.137])\n\tby ip-10-39-136-77 (Postfix) with ESMTP id 7B8A62C110C\n\tfor jordan@test.com; Wed, 25 Nov 2015 09:43:15 +0000 (UTC)\nX-Alimail-AntiSpam:AC=CONTINUE;BC=0.4743358|-1;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03290;MF=jordan@example.com;NM=1;PH=DS;RN=2;RT=2;SR=0;TI=SMTPD----4GMFKN4;\nReceived: from 192.168.100.163(mailfrom:jordan@example.com ip:63.251.90.2)\n by smtp.aliyun-inc.com(10.147.35.236);\n Wed, 25 Nov 2015 17:43:13 +0800\nFrom: Aliyun jordan@example.com\nContent-Type: text\/plain; charset=us-ascii\nContent-Transfer-Encoding: 7bit\nSubject: Directly\nDate: Wed, 25 Nov 2015 17:43:06 +0800\nMessage-Id: CF225FFC-E139-4674-8E70-3E5E9ACBF453@example.com\nCc: Aliyun jordan@example.com\nTo: jordan@test.com\nMime-Version: 1.0 (Mac OS X Mail 9.0 \(3094\))\nX-Mailer: Apple Mail (2.3094)\n\nDirectly.\",\"headers\":{\"Received\":[\"from out1134-137.mail.aliyun.com (unknown [42.120.134.137]) by ip-10-39-136-77 (Postfix) with ESMTP id 7B8A62C110C for jordan@test.com; Wed, 25 Nov 2015 09:43:15 +0000 (UTC)\",\"from 192.168.100.163(mailfrom:jordan@example.com ip:63.251.90.2) by smtp.aliyun-inc.com(10.147.35.236); Wed, 25 Nov 2015 17:43:13 +0800\"],\"X-Alimail-Antispam\":\"AC=CONTINUE;BC=0.4743358|-1;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03290;MF=jordan@example.com;NM=1;PH=DS;RN=2;RT=2;SR=0;TI=SMTPD_----4GMFKN4;\",\"From\":\"Aliyun jordan@example.com\",\"Content-Type\":\"text\/plain; charset=us-ascii\",\"Content-Transfer-Encoding\":\"7bit\",\"Subject\":\"Directly\",\"Date\":\"Wed, 25 Nov 2015 17:43:06 +0800\",\"Message-Id\":\"CF225FFC-E139-4674-8E70-3E5E9ACBF453@example.com\",\"Cc\":\"Aliyun jordan@example.com\",\"To\":\"jordan@test.com\",\"Mime-Version\":\"1.0 (Mac OS X Mail 9.0 \(3094\))\",\"X-Mailer\":\"Apple Mail (2.3094)\"},\"text\":\"Directly.\",\"text_flowed\":false,\"from_email\":\"jordan@example.com\",\"from_name\":\"Aliyun\",\"to\":[[\"jordan@test.com\",null]],\"cc\":[[\"jordan@example.com\",\"Aliyun\"]],\"subject\":\"Directly\",\"spf\":{\"result\":\"pass\",\"detail\":\"sender SPF authorized\"},\"spam_report\":{\"score\":1.3,\"matched_rules\":[{\"name\":\"RCVD_IN_DNSWL_NONE\",\"score\":-0,\"description\":\"RBL: Sender listed at http:\/\/www.dnswl.org\/, no\"},{\"name\":null,\"score\":0,\"description\":null},{\"name\":\"listed\",\"score\":0,\"description\":\"in list.dnswl.org]\"},{\"name\":\"RDNS_NONE\",\"score\":1.3,\"description\":\"Delivered to internal network by a host with no rDNS\"},{\"name\":\"UNPARSEABLE_RELAY\",\"score\":0,\"description\":\"Informational: message has unparseable relay lines\"}]},\"dkim\":{\"signed\":false,\"valid\":false},\"email\":\"jordan@test.com\",\"tags\":[],\"sender\":null,\"template\":null}}]"}

echan00 commented 8 years ago

@xinlangzi yes we have the same problem. I dont think its a problem with mandrill? Since the mail params exist my guess is griddler had trouble parsing those params?

xinlangzi commented 8 years ago

I see the problem is about the SPF and DKIM. Do you use the subdomain for inbound email?

2015-11-26 0:00 GMT+08:00 Erik Chan notifications@github.com:

@xinlangzi https://github.com/xinlangzi yes we have the same problem. I dont think its a problem with mandrill? Since the mail params exist my guess is griddler had trouble parsing those params?

— Reply to this email directly or view it on GitHub https://github.com/thoughtbot/griddler/issues/236#issuecomment-159654615 .

Blessings, Jordan

Website: www.pracstrat.com Phone: 15280210400 Address: Wanghai Road 55#B302, Software Park#2, Xiamen, FJ, PRC

echan00 commented 8 years ago

yes, i use a subdomain for inbound mail. E.g xxx@subdomain.domain.com

SPF and DKIM is only for sending emails?

echan00 commented 8 years ago

Ping!

Would love to hear what the Griddler folks think, @gabebw? :) My guess is this is a griddler issue..

xinlangzi commented 8 years ago

Erik,

I just make a money patch in my rails project to accept whatever SPF is.

Blessings, Jordan

2015-12-02 5:52 GMT+08:00 Erik Chan notifications@github.com:

Ping!

Would love to hear what the Griddler folks think :) my guess is this is a griddler issue.

— Reply to this email directly or view it on GitHub https://github.com/thoughtbot/griddler/issues/236#issuecomment-161107261 .

Blessings, Jordan

Website: www.pracstrat.com Phone: 15280210400 Address: Wanghai Road 55#B302, Software Park#2, Xiamen, FJ, PRC

echan00 commented 8 years ago

@xinlangzi Could you show me what you did? It would be really useful..

xinlangzi commented 8 years ago

Very simple:

module Griddler module Mandrill class Adapter

  def normalize_params
    events.select do |event|
      event[:spf].present? ####&& (event[:spf][:result] == 'pass' ||

event[:spf][:result] == 'neutral') end.map do |event| { to: recipients(:to, event), cc: recipients(:cc, event), bcc: resolve_bcc(event), headers: event[:headers], from: full_email([ event[:from_email], event[:from_name] ]), subject: event[:subject], text: event[:text] || '', html: event[:html] || '', raw_body: event[:raw_msg], attachments: attachment_files(event), email: event[:email] # the email address where Mandrill received the message } end end end end end

2015-12-02 10:32 GMT+08:00 Erik Chan notifications@github.com:

@xinlangzi https://github.com/xinlangzi Could you show me what you did? It would be really useful..

— Reply to this email directly or view it on GitHub https://github.com/thoughtbot/griddler/issues/236#issuecomment-161159998 .

Blessings, Jordan

Website: www.pracstrat.com Phone: 15280210400 Address: Wanghai Road 55#B302, Software Park#2, Xiamen, FJ, PRC

echan00 commented 8 years ago

More info here: https://github.com/wingrunr21/griddler-mandrill/issues/23

Thanks @xinlangzi

wingrunr21 commented 8 years ago

Closing as this is related to an issue in griddler-mandrill