Created
September 15, 2014 23:23
-
-
Save isaiahbaca/ceecadcb1d47ac7208a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'httpi' # Use whatever http system you've already started using | |
require 'json' | |
require 'oj' | |
@foolio =10.times.map{ 20 + Random.rand(11) } | |
mandrill_events = <<EOD | |
[{\"event\":\"inbound\",\"ts\":1405360537,\"msg\":{\"raw_msg\":\"Received: #{ARGV[1]} (unknown [209.85.219.44])\\n\\tby ip-10-196-133-123 (Postfix) with ESMTPS id D5E14802B1\\n\\tfor <transaction@thunderd | |
ome.atpay.com>; Mon, 14 Jul 2014 17:55:34 +0000 (UTC)\\nReceived: by mail-oa0-f44.google.com with SMTP id eb12so4621363oac.3\\n for <[email protected]>; Mon, 14 Jul 2014 10:55:34 -0 | |
700 (PDT)\\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed\\/relaxed;\\n d=atpay.com; s=google;\\n h=mime-version:date:message-id:subject:from:to:content-type;\\n bh=gasd7uFaI3aQI8OuMXI | |
sbr7h77WsIr8yryAKcqq0VWATNk=;\\n b=e6Bd6S\\/FY+9vcVFVUzRq8u4O2BodKJeabWoHae7qwLIndcCFfw\\/FhHmTrOHu5GQoms\\n 5\\/H9slpoPAbG0qZc\\/wHrrjbPF7TRQNLK10lvgGn1Xubgd0PYZ4qwuiQkisR\\/6Fn9U0A2\\n | |
T407aTXAGLxfLtgU24U2NQB193sn+1pZ0uKzM=\\nX-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed\\/relaxed;\\n d=1e100.net; s=20130820;\\n h=x-gm-message-state:mime-version:date:message- | |
id:subject:from:to\\n :content-type;\\n bh=g7uFaI3aQI8OuMXIsbr7h77WsIr8yryAKcqq0VWATNk=;\\n b=cnqLEoV15onCIr+9FuumdJ4fZLsvEYDWk79Y8ClPeFQ6NctqZELwqKn0xx\\/U6IFPeb\\n ZZAiRNyD | |
mxk2c6mqq+iFcaWSWp4RZRaPbfB8p16pIeogXAhGZCwhk\\/v2lbd5qki0ZkxF\\n xKc298fpM7iCGBPo9CUUE7Chjy4GBqmY4Wz1CCTJqNBGEJA23dx+kzMH7rsrr7iGZRr2\\n D4Jq5VWEETUSOrThizl7\\/mWCcOQlmuiX8WhlQPVC1Wv+4pt6 | |
ax8qxrIPRCaBnOOvm1vy\\n EC1LCo\\/fGDCXlg2XQJWZ4k26KA9zCYlD\\/BaRAYqcTr0qN7JLWJbxe11dW02YmDxbjGzE\\n w1bg==\\nX-Gm-Message-State: ALoCoQlW5rAozy9hKiW3wEsULw8u0S\\/1ZsObfuSy\\/QbnU9PvzAyeRq7 | |
IHsd4jmHTa1icUNAPunlf\\nMIME-Version: 1.0\\nX-Received: by 10.60.164.101 with SMTP id yp5mr19688792oeb.59.1405360534038;\\n Mon, 14 Jul 2014 10:55:34 -0700 (PDT)\\nReceived: by 10.182.192.103 with HTTP; M | |
on, 14 Jul 2014 10:55:33 -0700 (PDT)\\nDate: Mon, 14 Jul 2014 11:55:33 -0600\\nMessage-ID: <CAPobLRt3J23p0ODWxQ01eMhBjXUi05aG=7zavD_GvDbF_aSv6w@mail.gmail.com>\\nSubject: \\nFrom: Isaiah Baca <me@isaiahb. | |
com>\\nTo: [email protected]\\nContent-Type: multipart\\/alternative; boundary=047d7b33981369c1d504fe2aff39\\n\\n--047d7b33981369c1d504fe2aff39\\nContent-Type: text\\/plain; charset=UTF-8\ | |
\n\\n#{ARGV[0]}\\n\\n--047d7b33981369c1d504fe2aff39\\nContent-Type: text\\/html; charset=UTF-8\\n\\n<div dir=\\\"ltr\\\"> #{ARGV[0]} #{@foolio} <br><\\/div>\\n\\n--047d7b33981369c1d504fe2aff39--\",\"hea | |
ders\":{\"Received\":[\"from mail-oa0-f44.google.com (unknown [209.85.219.44]) by ip-10-196-133-123 (Postfix) with ESMTPS id D5E14802B1 for <[email protected]>; Mon, 14 Jul 2014 17:55:34 + | |
0000 (UTC)\",\"by mail-oa0-f44.google.com with SMTP id eb12so4621363oac.3 for <[email protected]>; Mon, 14 Jul 2014 10:55:34 -0700 (PDT)\",\"by 10.182.192.103 with HTTP; Mon, 14 Jul 2014 1 | |
0:55:33 -0700 (PDT)\"],\"Dkim-Signature\":\"v=1; a=rsa-sha256; c=relaxed\\/relaxed; d=atpay.com; s=google; h=mime-version:date:message-id:subject:from:to:content-type; bh=g7uFaI3aQI8OuMXIsbr7h77WsIr8yryAK | |
cqq0VWATNk=; b=e6Bd6S\\/FY+9vcVFVUzRq8u4O2BodKJeabWoHae7qwLIndcCFfw\\/FhHmTrOHu5GQoms 5\\/H9slpoPAbG0qZc\\/wHrrjbPF7TRQNLK10lvgGn1Xubgd0PYZ4qwuiQkisR\\/6Fn9U0A2 T407aTXAGLxfLtgU24U2NQB193sn+1pZ0uKzM=\",\" | |
X-Google-Dkim-Signature\":\"v=1; a=rsa-sha256; c=relaxed\\/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=g7uFaI3aQI8OuMXIsbr7h77WsIr | |
8yryAKcqq0VWATNk=; b=cnqLEoV15onCIr+9FuumdJ4fZLsvEYDWk79Y8ClPeFQ6NctqZELwqKn0xx\\/U6IFPeb ZZAiRNyDmxk2c6mqq+iFcaWSWp4RZRaPbfB8p16pIeogXAhGZCwhk\\/v2lbd5qki0ZkxF xKc298fpM7iCGBPo9CUUE7Chjy4GBqmY4Wz1CCTJqNB | |
GEJA23dx+kzMH7rsrr7iGZRr2 D4Jq5VWEETUSOrThizl7\\/mWCcOQlmuiX8WhlQPVC1Wv+4pt6ax8qxrIPRCaBnOOvm1vy EC1LCo\\/fGDCXlg2XQJWZ4k26KA9zCYlD\\/BaRAYqcTr0qN7JLWJbxe11dW02YmDxbjGzE w1bg==\",\"X-Gm-Message-State\":\" | |
ALoCoQlW5rAozy9hKiW3wEsULw8u0S\\/1ZsObfuSy\\/QbnU9PvzAyeRq7IHsd4jmHTa1icUNAPunlf\",\"Mime-Version\":\"1.0\",\"X-Received\":\"by 10.60.164.101 with SMTP id yp5mr19688792oeb.59.1405360534038; Mon, 14 Jul 20 | |
14 10:55:34 -0700 (PDT)\",\"Date\":\"Mon, 14 Jul 2014 11:55:33 -0600\",\"Message-Id\":\"<CAPobLRt3J23p0ODWxQ01eMhBjXUi05aG=7zavD_GvDbF_aSv6w@mail.gmail.com>\",\"Subject\":\"\",\"From\":\"Isaiah Baca <#{AR | |
GV[1]}>\",\"To\":\"[email protected]\",\"Content-Type\":\"multipart\\/alternative; boundary=047d7b33981369c1d504fe2aff39\"},\"text\":\"#{ARGV[0]}\\n\\n\",\"text_flowed\":false,\"html\":\"< | |
div dir=\\\"ltr\\\">#{ARGV[0]}<br><\\/div>\\n\\n\",\"from_email\":\"#{ARGV[1]}\",\"from_name\":\"Isaiah Baca\",\"to\":[[\"[email protected]\",null]],\"subject\":\"\",\"spf\":{\"result\":\" | |
permerror\",\"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.dn | |
swl.org\\/, low\"},{\"name\":null,\"score\":0,\"description\":null},{\"name\":\"listed\",\"score\":0,\"description\":\"in list.dnswl.org]\"},{\"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\",\"sco | |
re\":1.3,\"description\":\"Delivered to internal network by a host with no rDNS\"},{\"name\":\"TVD_SPACE_RATIO\",\"score\":0,\"description\":\"TVD_SPACE_RATIO\"}]},\"dkim\":{\"signed\":true,\"valid\":true | |
},\"email\":\"[email protected]\",\"tags\":[],\"sender\":null,\"template\":null}}] | |
EOD | |
mandrill_events = Oj.dump(Oj.load(mandrill_events)) | |
request = HTTPI::Request.new("https://dashboard.atpay.com/email_transactions/") | |
request.body = { mandrill_events: mandrill_events } | |
request.headers["X-Mandrill-Signature"] = "LnD7n+C2hxeoLVnLaMmIFE7EJ/s=" | |
request.headers["HTTP_X_MANDRILL_SIGNATURE"] = "LnD7n+C2hxeoLVnLaMmIFE7EJ/s=" | |
HTTPI.post(request) | |
~ |
APP_BASE="https://dashboard.atpay.com"
when i repost to my local, i can verify that the headers are being set:
[2] pry(MandrillInboundEmail::Signature)> rails_request.headers["X-Mandrill-Signature"]
=> "LnD7n+C2hxeoLVnLaMmIFE7EJ/s="
[3] pry(MandrillInboundEmail::Signature)> rails_request.headers["HTTP_X_MANDRILL_SIGNATURE"]
=> "LnD7n+C2hxeoLVnLaMmIFE7EJ/s="
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MANDRILL_INCOMING_HOOK_KEYS_LIST="Q6AsTVFGRDyKpdK_VrBaNw,d9cbV1rY9FKoZzDkPyBVnw,MdwJgD8yJDjYsrwMvRaTHA,63tyGd-l1FkpM4mnnlVXYg,L21ClyYjdKobv9X9KnRe_g"