Can write to database
authorNeil Smith <neil.git@njae.me.uk>
Tue, 29 Mar 2016 11:04:26 +0000 (12:04 +0100)
committerNeil Smith <neil.git@njae.me.uk>
Tue, 29 Mar 2016 11:04:26 +0000 (12:04 +0100)
.gitignore
read_report.ipynb
write-to-database.ipynb [new file with mode: 0644]

index 7703496952e81e3b9e482a5eaf2265b73e7a5227..e763a5e2a8fea6dd2e079930ac0a1a5c29326cf7 100644 (file)
@@ -46,3 +46,6 @@ nosetests.xml
 
 # Config file
 dmarc.ini
+
+# DMARC reports
+*xml
index 1cf8a2ab5051f2df72b01a851ef54fa61546b432..b5bf2dfa8ab027fd17406d29d6f336eab07de508 100644 (file)
@@ -52,7 +52,7 @@
     {
      "data": {
       "text/plain": [
-       "['server', 'username', 'port', 'password']"
+       "[]"
       ]
      },
      "execution_count": 3,
     "[k for k in config['DEFAULT']]"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": 31,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "['imap', 'database']"
+      ]
+     },
+     "execution_count": 31,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "config.sections()"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": 4,
     }
    ],
    "source": [
-    "config['DEFAULT']['server']"
+    "config['imap']['server']"
    ]
   },
   {
    },
    "outputs": [],
    "source": [
-    "mailbox = imaplib.IMAP4(host=config['DEFAULT']['server'], \n",
-    "                      port=config['DEFAULT']['port'])"
+    "mailbox = imaplib.IMAP4(host=config['imap']['server'], \n",
+    "                      port=config['imap']['port'])"
    ]
   },
   {
     }
    ],
    "source": [
-    "mailbox.login(config['DEFAULT']['username'], config['DEFAULT']['password'])"
+    "mailbox.login(config['imap']['username'], config['imap']['password'])"
    ]
   },
   {
     {
      "data": {
       "text/plain": [
-       "('OK', [b'169'])"
+       "('OK', [b'172'])"
       ]
      },
      "execution_count": 8,
      "data": {
       "text/plain": [
        "('OK',\n",
-       " [b'1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169'])"
+       " [b'1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172'])"
       ]
      },
      "execution_count": 9,
     {
      "data": {
       "text/plain": [
-       "('OK', [b'164 165 166 167 168 169'])"
+       "('OK', [b'164 165 166 167 168 169 170 171 172'])"
       ]
      },
      "execution_count": 10,
     {
      "data": {
       "text/plain": [
-       "[b'164', b'165', b'166', b'167', b'168', b'169']"
+       "[b'164', b'165', b'166', b'167', b'168', b'169', b'170', b'171', b'172']"
       ]
      },
      "execution_count": 11,
      "data": {
       "text/plain": [
        "('OK',\n",
-       " [(b'169 (RFC822 {4480}',\n",
-       "   b'Return-Path: <noreply-dmarc-support@google.com>\\r\\nDelivered-To: dmarc@njae.me.uk\\r\\nReceived: from localhost (localhost [127.0.0.1])\\r\\n\\tby mail.njae.me.uk (Postfix) with ESMTP id 2A065106\\r\\n\\tfor <dmarc@njae.me.uk>; Sun, 27 Mar 2016 10:28:09 +0100 (BST)\\r\\nX-Virus-Scanned: Debian amavisd-new at njae.me.uk\\r\\nAuthentication-Results: ogedei.njae.me.uk (amavisd-new);\\r\\n\\tdkim=pass (2048-bit key) header.d=google.com\\r\\nReceived: from mail.njae.me.uk ([127.0.0.1])\\r\\n\\tby localhost (ogedei.njae.me.uk [127.0.0.1]) (amavisd-new, port 10024)\\r\\n\\twith ESMTP id S06rrC9pLQlu for <dmarc@njae.me.uk>;\\r\\n\\tSun, 27 Mar 2016 10:28:07 +0100 (BST)\\r\\nReceived-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.223.201; helo=mail-io0-f201.google.com; envelope-from=noreply-dmarc-support@google.com; receiver=dmarc@njae.me.uk \\r\\nAuthentication-Results: mail.njae.me.uk; dmarc=pass header.from=google.com\\r\\nAuthentication-Results: mail.njae.me.uk; dkim=pass\\r\\n\\treason=\"2048-bit key; unprotected key\"\\r\\n\\theader.d=google.com header.i=@google.com header.b=kRG+/uqj;\\r\\n\\tdkim-adsp=pass; dkim-atps=neutral\\r\\nReceived: from mail-io0-f201.google.com (mail-io0-f201.google.com [209.85.223.201])\\r\\n\\tby mail.njae.me.uk (Postfix) with ESMTPS id 36952EB\\r\\n\\tfor <dmarc@njae.me.uk>; Sun, 27 Mar 2016 10:28:06 +0100 (BST)\\r\\nReceived: by mail-io0-f201.google.com with SMTP id 124so13927004iov.0\\r\\n        for <dmarc@njae.me.uk>; Sun, 27 Mar 2016 02:28:06 -0700 (PDT)\\r\\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\\r\\n        d=google.com; s=20120113;\\r\\n        h=mime-version:message-id:date:subject:from:to:content-disposition\\r\\n         :content-transfer-encoding;\\r\\n        bh=WebWWyH674VepKwkY7+3OEpaPDkuJsYet/WYzuiqEhc=;\\r\\n        b=kRG+/uqjzLNy4IsueOq2bd1CW4i2x4dzf5Dg+soCJzKTycsrUudvIkphybOCPAE4aW\\r\\n         1ffplA6Tt9mxOpAfYppahUPeWFXtCE5AEf3/qorGxcv/yHv8S3TFiUqulTLccOyLbhoG\\r\\n         P02OxDg38XWHLob7gOKUsqdCAmPfxqATsvakVN/SJkJswU4Fm8iBBaoca7wgW/A97eJs\\r\\n         zKnmyWvpc1juUp5YLYWVGwL9927tbw8bO+0acz53Qgwj+QScqSftMNeLzKS3Ct11RkvX\\r\\n         W49XblUJOHS+lbtVF6radeGKbsGp09QClMLAyLKEUeYTTgux/K0CIuB3A+BmQ1O3Souk\\r\\n         cN7A==\\r\\nX-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\\r\\n        d=1e100.net; s=20130820;\\r\\n        h=x-gm-message-state:mime-version:message-id:date:subject:from:to\\r\\n         :content-disposition:content-transfer-encoding;\\r\\n        bh=WebWWyH674VepKwkY7+3OEpaPDkuJsYet/WYzuiqEhc=;\\r\\n        b=iy79Cfu0C9JtwPWMHnqS7hbVnFOcPMPttWMomjdh1ekeq+jxAg9335NteUoNg79PTo\\r\\n         QSJbg9YAM4bvlFPOcPrSNQN+Q5fdopi1TuDBgHK7L0Rb9Vv8eKVRSG8pyLAw7Izs+y/H\\r\\n         9Rlh8qfOV3Te/pzQb+4eA+SS39D9O8L1Cmg2p19Y+XmNfX8xd/UhIKzXNNSbQODMOwnL\\r\\n         xw0wmbMu/3wMgnUgJVfcp7BkZVhJzO7CqNfkGlv4BSpSGEH2+I0AwZFQgLfytwJ4j3nh\\r\\n         oH217zO+us6vAE2gV3zneO4X3Pf88J7ma+I7Et6Bl2cM1TunPpisx6aqnzPdIMhJwMDt\\r\\n         GM+w==\\r\\nX-Gm-Message-State: AD7BkJIXsS+d+n0kHSQlvoPQuXFYd9jWCwS846F7EdDD9cR1K1RkBPs0SrrYY9ARYXU/K7Bs7gdjAw==\\r\\nMIME-Version: 1.0\\r\\nX-Received: by 10.157.11.13 with SMTP id a13mr14086672ota.35.1459070885519;\\r\\n Sun, 27 Mar 2016 02:28:05 -0700 (PDT)\\r\\nMessage-ID: <2150510829392606201@google.com>\\r\\nDate: Sun, 27 Mar 2016 09:28:05 +0000\\r\\nSubject: Report domain: njae.me.uk Submitter: google.com Report-ID: 2150510829392606201\\r\\nFrom: noreply-dmarc-support@google.com\\r\\nTo: dmarc@njae.me.uk\\r\\nContent-Type: application/zip; \\r\\n\\tname=\"google.com!njae.me.uk!1458950400!1459036799.zip\"\\r\\nContent-Disposition: attachment; \\r\\n\\tfilename=\"google.com!njae.me.uk!1458950400!1459036799.zip\"\\r\\nContent-Transfer-Encoding: base64\\r\\n\\r\\nUEsDBAoAAAAIADpKe0gTM/X5EAIAAKsGAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTg5\\r\\nNTA0MDAhMTQ1OTAzNjc5OS54bWzVVU1vnDAQvedXoL0vBrJQqBynp/6C9oy8ZmDdBduyTZL99zVr\\r\\n85FNKkVVpKqnNW9m3swbP1j8+DL00RNow6V42KVxsotAMNlw0T3sfv74vi930SO5wy1Ac6TsTO6i\\r\\nCGtQUtt6AEsbaumEOVTqrhZ0ANJJ2fUQMzlgtIA+BwbKeyKkY+gv+2agmu3NqCa6b9synxdqXqym\\r\\nNZPCUmZrLlpJTtYq8xWhUBqvpYgiKswzaJQdiiIvE8f1tt4TBxm8IVmaJ3malFl1X2VFUmRJitEa\\r\\n9ulOKtSaii6IcdAROi5IesjLKk8OiWvmkTkOopmiVXJffKkqN4qYydBrtqXbdqdYyZ6zS63GY8/N\\r\\nCZZBpNuOIOIXhXiAeDw7Ng/5OG3OfCAaI38IoFHtFZt+PaTcRQjASIVnMwNmRhSzJJ1kTYfrmO+N\\r\\n5BbJpJ6n0/J50W/kqBnUXJEyi9OkitPyELs9rPicyeQoXC+M/GGGQzt4ov3oFtbMgWkL3ChpuHXG\\r\\nDWNvkU3etIPW2cklLOsIetsQWHaykXjT093QLAzzBoTlLXevzVJ2AtqArlsth1c3s8UD0ZtyTEd7\\r\\nqjWYsbcr48204YpZ71bfy0tj/Juyvfng6omGKGrM5Krrw6Jty4k3qj+LfzUXutU0Jc82+YhjsjSL\\r\\niyrO87jI/oFjvL53HOMD/5Fj/vSd+Ay3/D33h5yC0fq/8xtQSwECCgAKAAAACAA6SntIEzP1+RAC\\r\\nAACrBgAALwAAAAAAAAAAAAAAAAAAAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTg5NTA0MDAh\\r\\nMTQ1OTAzNjc5OS54bWxQSwUGAAAAAAEAAQBdAAAAXQIAAAAA\\r\\n'),\n",
+       " [(b'172 (RFC822 {4406}',\n",
+       "   b'Return-Path: <noreply-dmarc-support@google.com>\\r\\nDelivered-To: dmarc@njae.me.uk\\r\\nReceived: from localhost (localhost [127.0.0.1])\\r\\n\\tby mail.njae.me.uk (Postfix) with ESMTP id B966C8F\\r\\n\\tfor <dmarc@njae.me.uk>; Mon, 28 Mar 2016 11:11:48 +0100 (BST)\\r\\nX-Virus-Scanned: Debian amavisd-new at njae.me.uk\\r\\nAuthentication-Results: ogedei.njae.me.uk (amavisd-new);\\r\\n\\tdkim=pass (2048-bit key) header.d=google.com\\r\\nReceived: from mail.njae.me.uk ([127.0.0.1])\\r\\n\\tby localhost (ogedei.njae.me.uk [127.0.0.1]) (amavisd-new, port 10024)\\r\\n\\twith ESMTP id GOe6I1LLVNl9 for <dmarc@njae.me.uk>;\\r\\n\\tMon, 28 Mar 2016 11:11:47 +0100 (BST)\\r\\nReceived-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.223.202; helo=mail-io0-f202.google.com; envelope-from=noreply-dmarc-support@google.com; receiver=dmarc@njae.me.uk \\r\\nAuthentication-Results: mail.njae.me.uk; dmarc=pass header.from=google.com\\r\\nAuthentication-Results: mail.njae.me.uk; dkim=pass\\r\\n\\treason=\"2048-bit key; unprotected key\"\\r\\n\\theader.d=google.com header.i=@google.com header.b=FskZAi7J;\\r\\n\\tdkim-adsp=pass; dkim-atps=neutral\\r\\nReceived: from mail-io0-f202.google.com (mail-io0-f202.google.com [209.85.223.202])\\r\\n\\tby mail.njae.me.uk (Postfix) with ESMTPS id CDAA850\\r\\n\\tfor <dmarc@njae.me.uk>; Mon, 28 Mar 2016 11:11:46 +0100 (BST)\\r\\nReceived: by mail-io0-f202.google.com with SMTP id e3so1655636ioa.1\\r\\n        for <dmarc@njae.me.uk>; Mon, 28 Mar 2016 03:11:46 -0700 (PDT)\\r\\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\\r\\n        d=google.com; s=20120113;\\r\\n        h=mime-version:message-id:date:subject:from:to:content-disposition\\r\\n         :content-transfer-encoding;\\r\\n        bh=ZMmMsYb7psOB4wlBTQUv+llYFZLud7uqkJWOqTZoywc=;\\r\\n        b=FskZAi7J5MJ/Py4sgZaL4dHbNcmccPHDWlFnblx0RT0Dlfb35hDkjtYg5ageqyFowe\\r\\n         o4hDspB8+L7cBsY+ftdbMhneveFpKvDgwZqq/88iMOWLuUN39ZWMC7m/XIz2CZhUlLMz\\r\\n         xE25EhSOW9xiWWBOESZzIfCvSOoTuyfxMTUFq1uvARg2NUOAdrFTLTivAsMyK2RNkisM\\r\\n         SrQRcwDaMLIlQw6FzG+gsO3u8wrT6ckd0fHJtkGptab6CqhEwdkY3kJMCmiasoP/io2v\\r\\n         KEsQCkByjHJgnL4tFu5yznLggBrbbvdK4HonSGKDi7cHyuoImxaVZNVMQhaYRnyPqj7j\\r\\n         o08g==\\r\\nX-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\\r\\n        d=1e100.net; s=20130820;\\r\\n        h=x-gm-message-state:mime-version:message-id:date:subject:from:to\\r\\n         :content-disposition:content-transfer-encoding;\\r\\n        bh=ZMmMsYb7psOB4wlBTQUv+llYFZLud7uqkJWOqTZoywc=;\\r\\n        b=OJjK6bq/e//bsrZJ503gIDT0b582UN5hgfMRT+iJVwtH7ombD4ld+S/+NOfWVTwq8J\\r\\n         FoHVodNZjznUtkoOVOm3BFbliMPyxHoYKdbWyYgYH5KzlD9Iv81N5djl50nxdWNkbhK1\\r\\n         CZHike9tfLHF82v6i8BIRMubK8UHyCCOpVgFMM+GK3tTdyA7BY/0jXNqzfTDbS/FyeoW\\r\\n         sH/sckfOf4HN9DRgNbZ78aq5c1bAcx/N7Fn7+53uLBxw82XUd7JFi10kMd3jvPbHMORa\\r\\n         YQgyPoQxuQPvjfU0KTJiXQt+iP+ksHl0DO9umo+c5WzLdHk8QV1ryS5OEhUrfaORqK8a\\r\\n         0d9g==\\r\\nX-Gm-Message-State: AD7BkJLC5599FbOXiJoIKq3UlGXdkIr5BkghJuDHCJeDAQVhAr64/XYgB+fejr5uDj8FvDHPPSPVXA==\\r\\nMIME-Version: 1.0\\r\\nX-Received: by 10.182.243.135 with SMTP id wy7mr16780454obc.8.1459159905131;\\r\\n Mon, 28 Mar 2016 03:11:45 -0700 (PDT)\\r\\nMessage-ID: <16143280651570354241@google.com>\\r\\nDate: Mon, 28 Mar 2016 10:11:45 +0000\\r\\nSubject: Report domain: njae.me.uk Submitter: google.com Report-ID: 16143280651570354241\\r\\nFrom: noreply-dmarc-support@google.com\\r\\nTo: dmarc@njae.me.uk\\r\\nContent-Type: application/zip; \\r\\n\\tname=\"google.com!njae.me.uk!1459036800!1459123199.zip\"\\r\\nContent-Disposition: attachment; \\r\\n\\tfilename=\"google.com!njae.me.uk!1459036800!1459123199.zip\"\\r\\nContent-Transfer-Encoding: base64\\r\\n\\r\\nUEsDBAoAAAAIAD1PfEjhndhx2QEAAHoEAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTkw\\r\\nMzY4MDAhMTQ1OTEyMzE5OS54bWytVMtyozAQvOcrKN+NEAbW3lKUPeULds+ULAasNUgqSeTx9yss\\r\\n8YiTqlz2hOiZ6ZnuEZCnt6FPXsBYoeTjDqfZLgHJVSNk97j78/t5f9wlT/SBtADNmfErfUgSYkAr\\r\\n4+oBHGuYYxPmUWW6WrIBaKdU10PK1UDQAoYcGJjoqVSeoX/fNwMzfG9HPdH92paFvFjz5gyruZKO\\r\\ncVcL2Sp6cU7bnwjF0nQtRQwxaV/BoLyoqvKYea7P9YE4yhANxRUuDvkxq0pc/sgOZZEXmKA1HvK9\\r\\nVqgNk11U46EzdEJSXJSn7FAdM98tIHMcZHOL4vyATyc/i5zJ0Ee2pdvWVKJVL/h7rcdzL+wFlkGU\\r\\nt0dS+ZdBOkA6Xj1bgEKcNVcxUENQOETQ6vaGTc8Aab8JCQTp+G5nwM6I5o7iSdZ0uI351UjeSa7M\\r\\nPJ1Rr4t+q0bDoRaa5jhPq1NalmmV+wYLPmdyNUpHfSgcZji2gxfWj96wZg5MLgirlRXO39w49hbZ\\r\\n5E0eaGatT1jsiHrbGFg82Ui86+k3NAsjogHpRCv8d7OUXYA1YOrWqOHDZrZ4JPpUTtjoLrUBO/Zu\\r\\nZbyb9putxys9UURR8WXRteUjG8X/g3u9VOhey5QcrgdB62/kH1BLAQIKAAoAAAAIAD1PfEjhndhx\\r\\n2QEAAHoEAAAvAAAAAAAAAAAAAAAAAAAAAABnb29nbGUuY29tIW5qYWUubWUudWshMTQ1OTAzNjgw\\r\\nMCExNDU5MTIzMTk5LnhtbFBLBQYAAAAAAQABAF0AAAAmAgAAAAA=\\r\\n'),\n",
        "  b')'])"
       ]
      },
       "Return-Path: <noreply-dmarc-support@google.com>\r\n",
       "Delivered-To: dmarc@njae.me.uk\r\n",
       "Received: from localhost (localhost [127.0.0.1])\r\n",
-      "\tby mail.njae.me.uk (Postfix) with ESMTP id 2A065106\r\n",
-      "\tfor <dmarc@njae.me.uk>; Sun, 27 Mar 2016 10:28:09 +0100 (BST)\r\n",
+      "\tby mail.njae.me.uk (Postfix) with ESMTP id B966C8F\r\n",
+      "\tfor <dmarc@njae.me.uk>; Mon, 28 Mar 2016 11:11:48 +0100 (BST)\r\n",
       "X-Virus-Scanned: Debian amavisd-new at njae.me.uk\r\n",
       "Authentication-Results: ogedei.njae.me.uk (amavisd-new);\r\n",
       "\tdkim=pass (2048-bit key) header.d=google.com\r\n",
       "Received: from mail.njae.me.uk ([127.0.0.1])\r\n",
       "\tby localhost (ogedei.njae.me.uk [127.0.0.1]) (amavisd-new, port 10024)\r\n",
-      "\twith ESMTP id S06rrC9pLQlu for <dmarc@njae.me.uk>;\r\n",
-      "\tSun, 27 Mar 2016 10:28:07 +0100 (BST)\r\n",
-      "Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.223.201; helo=mail-io0-f201.google.com; envelope-from=noreply-dmarc-support@google.com; receiver=dmarc@njae.me.uk \r\n",
+      "\twith ESMTP id GOe6I1LLVNl9 for <dmarc@njae.me.uk>;\r\n",
+      "\tMon, 28 Mar 2016 11:11:47 +0100 (BST)\r\n",
+      "Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.223.202; helo=mail-io0-f202.google.com; envelope-from=noreply-dmarc-support@google.com; receiver=dmarc@njae.me.uk \r\n",
       "Authentication-Results: mail.njae.me.uk; dmarc=pass header.from=google.com\r\n",
       "Authentication-Results: mail.njae.me.uk; dkim=pass\r\n",
       "\treason=\"2048-bit key; unprotected key\"\r\n",
-      "\theader.d=google.com header.i=@google.com header.b=kRG+/uqj;\r\n",
+      "\theader.d=google.com header.i=@google.com header.b=FskZAi7J;\r\n",
       "\tdkim-adsp=pass; dkim-atps=neutral\r\n",
-      "Received: from mail-io0-f201.google.com (mail-io0-f201.google.com [209.85.223.201])\r\n",
-      "\tby mail.njae.me.uk (Postfix) with ESMTPS id 36952EB\r\n",
-      "\tfor <dmarc@njae.me.uk>; Sun, 27 Mar 2016 10:28:06 +0100 (BST)\r\n",
-      "Received: by mail-io0-f201.google.com with SMTP id 124so13927004iov.0\r\n",
-      "        for <dmarc@njae.me.uk>; Sun, 27 Mar 2016 02:28:06 -0700 (PDT)\r\n",
+      "Received: from mail-io0-f202.google.com (mail-io0-f202.google.com [209.85.223.202])\r\n",
+      "\tby mail.njae.me.uk (Postfix) with ESMTPS id CDAA850\r\n",
+      "\tfor <dmarc@njae.me.uk>; Mon, 28 Mar 2016 11:11:46 +0100 (BST)\r\n",
+      "Received: by mail-io0-f202.google.com with SMTP id e3so1655636ioa.1\r\n",
+      "        for <dmarc@njae.me.uk>; Mon, 28 Mar 2016 03:11:46 -0700 (PDT)\r\n",
       "DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n",
       "        d=google.com; s=20120113;\r\n",
       "        h=mime-version:message-id:date:subject:from:to:content-disposition\r\n",
       "         :content-transfer-encoding;\r\n",
-      "        bh=WebWWyH674VepKwkY7+3OEpaPDkuJsYet/WYzuiqEhc=;\r\n",
-      "        b=kRG+/uqjzLNy4IsueOq2bd1CW4i2x4dzf5Dg+soCJzKTycsrUudvIkphybOCPAE4aW\r\n",
-      "         1ffplA6Tt9mxOpAfYppahUPeWFXtCE5AEf3/qorGxcv/yHv8S3TFiUqulTLccOyLbhoG\r\n",
-      "         P02OxDg38XWHLob7gOKUsqdCAmPfxqATsvakVN/SJkJswU4Fm8iBBaoca7wgW/A97eJs\r\n",
-      "         zKnmyWvpc1juUp5YLYWVGwL9927tbw8bO+0acz53Qgwj+QScqSftMNeLzKS3Ct11RkvX\r\n",
-      "         W49XblUJOHS+lbtVF6radeGKbsGp09QClMLAyLKEUeYTTgux/K0CIuB3A+BmQ1O3Souk\r\n",
-      "         cN7A==\r\n",
+      "        bh=ZMmMsYb7psOB4wlBTQUv+llYFZLud7uqkJWOqTZoywc=;\r\n",
+      "        b=FskZAi7J5MJ/Py4sgZaL4dHbNcmccPHDWlFnblx0RT0Dlfb35hDkjtYg5ageqyFowe\r\n",
+      "         o4hDspB8+L7cBsY+ftdbMhneveFpKvDgwZqq/88iMOWLuUN39ZWMC7m/XIz2CZhUlLMz\r\n",
+      "         xE25EhSOW9xiWWBOESZzIfCvSOoTuyfxMTUFq1uvARg2NUOAdrFTLTivAsMyK2RNkisM\r\n",
+      "         SrQRcwDaMLIlQw6FzG+gsO3u8wrT6ckd0fHJtkGptab6CqhEwdkY3kJMCmiasoP/io2v\r\n",
+      "         KEsQCkByjHJgnL4tFu5yznLggBrbbvdK4HonSGKDi7cHyuoImxaVZNVMQhaYRnyPqj7j\r\n",
+      "         o08g==\r\n",
       "X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n",
       "        d=1e100.net; s=20130820;\r\n",
       "        h=x-gm-message-state:mime-version:message-id:date:subject:from:to\r\n",
       "         :content-disposition:content-transfer-encoding;\r\n",
-      "        bh=WebWWyH674VepKwkY7+3OEpaPDkuJsYet/WYzuiqEhc=;\r\n",
-      "        b=iy79Cfu0C9JtwPWMHnqS7hbVnFOcPMPttWMomjdh1ekeq+jxAg9335NteUoNg79PTo\r\n",
-      "         QSJbg9YAM4bvlFPOcPrSNQN+Q5fdopi1TuDBgHK7L0Rb9Vv8eKVRSG8pyLAw7Izs+y/H\r\n",
-      "         9Rlh8qfOV3Te/pzQb+4eA+SS39D9O8L1Cmg2p19Y+XmNfX8xd/UhIKzXNNSbQODMOwnL\r\n",
-      "         xw0wmbMu/3wMgnUgJVfcp7BkZVhJzO7CqNfkGlv4BSpSGEH2+I0AwZFQgLfytwJ4j3nh\r\n",
-      "         oH217zO+us6vAE2gV3zneO4X3Pf88J7ma+I7Et6Bl2cM1TunPpisx6aqnzPdIMhJwMDt\r\n",
-      "         GM+w==\r\n",
-      "X-Gm-Message-State: AD7BkJIXsS+d+n0kHSQlvoPQuXFYd9jWCwS846F7EdDD9cR1K1RkBPs0SrrYY9ARYXU/K7Bs7gdjAw==\r\n",
+      "        bh=ZMmMsYb7psOB4wlBTQUv+llYFZLud7uqkJWOqTZoywc=;\r\n",
+      "        b=OJjK6bq/e//bsrZJ503gIDT0b582UN5hgfMRT+iJVwtH7ombD4ld+S/+NOfWVTwq8J\r\n",
+      "         FoHVodNZjznUtkoOVOm3BFbliMPyxHoYKdbWyYgYH5KzlD9Iv81N5djl50nxdWNkbhK1\r\n",
+      "         CZHike9tfLHF82v6i8BIRMubK8UHyCCOpVgFMM+GK3tTdyA7BY/0jXNqzfTDbS/FyeoW\r\n",
+      "         sH/sckfOf4HN9DRgNbZ78aq5c1bAcx/N7Fn7+53uLBxw82XUd7JFi10kMd3jvPbHMORa\r\n",
+      "         YQgyPoQxuQPvjfU0KTJiXQt+iP+ksHl0DO9umo+c5WzLdHk8QV1ryS5OEhUrfaORqK8a\r\n",
+      "         0d9g==\r\n",
+      "X-Gm-Message-State: AD7BkJLC5599FbOXiJoIKq3UlGXdkIr5BkghJuDHCJeDAQVhAr64/XYgB+fejr5uDj8FvDHPPSPVXA==\r\n",
       "MIME-Version: 1.0\r\n",
-      "X-Received: by 10.157.11.13 with SMTP id a13mr14086672ota.35.1459070885519;\r\n",
-      " Sun, 27 Mar 2016 02:28:05 -0700 (PDT)\r\n",
-      "Message-ID: <2150510829392606201@google.com>\r\n",
-      "Date: Sun, 27 Mar 2016 09:28:05 +0000\r\n",
-      "Subject: Report domain: njae.me.uk Submitter: google.com Report-ID: 2150510829392606201\r\n",
+      "X-Received: by 10.182.243.135 with SMTP id wy7mr16780454obc.8.1459159905131;\r\n",
+      " Mon, 28 Mar 2016 03:11:45 -0700 (PDT)\r\n",
+      "Message-ID: <16143280651570354241@google.com>\r\n",
+      "Date: Mon, 28 Mar 2016 10:11:45 +0000\r\n",
+      "Subject: Report domain: njae.me.uk Submitter: google.com Report-ID: 16143280651570354241\r\n",
       "From: noreply-dmarc-support@google.com\r\n",
       "To: dmarc@njae.me.uk\r\n",
       "Content-Type: application/zip; \r\n",
-      "\tname=\"google.com!njae.me.uk!1458950400!1459036799.zip\"\r\n",
+      "\tname=\"google.com!njae.me.uk!1459036800!1459123199.zip\"\r\n",
       "Content-Disposition: attachment; \r\n",
-      "\tfilename=\"google.com!njae.me.uk!1458950400!1459036799.zip\"\r\n",
+      "\tfilename=\"google.com!njae.me.uk!1459036800!1459123199.zip\"\r\n",
       "Content-Transfer-Encoding: base64\r\n",
       "\r\n",
-      "UEsDBAoAAAAIADpKe0gTM/X5EAIAAKsGAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTg5\r\n",
-      "NTA0MDAhMTQ1OTAzNjc5OS54bWzVVU1vnDAQvedXoL0vBrJQqBynp/6C9oy8ZmDdBduyTZL99zVr\r\n",
-      "85FNKkVVpKqnNW9m3swbP1j8+DL00RNow6V42KVxsotAMNlw0T3sfv74vi930SO5wy1Ac6TsTO6i\r\n",
-      "CGtQUtt6AEsbaumEOVTqrhZ0ANJJ2fUQMzlgtIA+BwbKeyKkY+gv+2agmu3NqCa6b9synxdqXqym\r\n",
-      "NZPCUmZrLlpJTtYq8xWhUBqvpYgiKswzaJQdiiIvE8f1tt4TBxm8IVmaJ3malFl1X2VFUmRJitEa\r\n",
-      "9ulOKtSaii6IcdAROi5IesjLKk8OiWvmkTkOopmiVXJffKkqN4qYydBrtqXbdqdYyZ6zS63GY8/N\r\n",
-      "CZZBpNuOIOIXhXiAeDw7Ng/5OG3OfCAaI38IoFHtFZt+PaTcRQjASIVnMwNmRhSzJJ1kTYfrmO+N\r\n",
-      "5BbJpJ6n0/J50W/kqBnUXJEyi9OkitPyELs9rPicyeQoXC+M/GGGQzt4ov3oFtbMgWkL3ChpuHXG\r\n",
-      "DWNvkU3etIPW2cklLOsIetsQWHaykXjT093QLAzzBoTlLXevzVJ2AtqArlsth1c3s8UD0ZtyTEd7\r\n",
-      "qjWYsbcr48204YpZ71bfy0tj/Juyvfng6omGKGrM5Krrw6Jty4k3qj+LfzUXutU0Jc82+YhjsjSL\r\n",
-      "iyrO87jI/oFjvL53HOMD/5Fj/vSd+Ay3/D33h5yC0fq/8xtQSwECCgAKAAAACAA6SntIEzP1+RAC\r\n",
-      "AACrBgAALwAAAAAAAAAAAAAAAAAAAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTg5NTA0MDAh\r\n",
-      "MTQ1OTAzNjc5OS54bWxQSwUGAAAAAAEAAQBdAAAAXQIAAAAA\r\n",
+      "UEsDBAoAAAAIAD1PfEjhndhx2QEAAHoEAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTkw\r\n",
+      "MzY4MDAhMTQ1OTEyMzE5OS54bWytVMtyozAQvOcrKN+NEAbW3lKUPeULds+ULAasNUgqSeTx9yss\r\n",
+      "8YiTqlz2hOiZ6ZnuEZCnt6FPXsBYoeTjDqfZLgHJVSNk97j78/t5f9wlT/SBtADNmfErfUgSYkAr\r\n",
+      "4+oBHGuYYxPmUWW6WrIBaKdU10PK1UDQAoYcGJjoqVSeoX/fNwMzfG9HPdH92paFvFjz5gyruZKO\r\n",
+      "cVcL2Sp6cU7bnwjF0nQtRQwxaV/BoLyoqvKYea7P9YE4yhANxRUuDvkxq0pc/sgOZZEXmKA1HvK9\r\n",
+      "VqgNk11U46EzdEJSXJSn7FAdM98tIHMcZHOL4vyATyc/i5zJ0Ee2pdvWVKJVL/h7rcdzL+wFlkGU\r\n",
+      "t0dS+ZdBOkA6Xj1bgEKcNVcxUENQOETQ6vaGTc8Aab8JCQTp+G5nwM6I5o7iSdZ0uI351UjeSa7M\r\n",
+      "PJ1Rr4t+q0bDoRaa5jhPq1NalmmV+wYLPmdyNUpHfSgcZji2gxfWj96wZg5MLgirlRXO39w49hbZ\r\n",
+      "5E0eaGatT1jsiHrbGFg82Ui86+k3NAsjogHpRCv8d7OUXYA1YOrWqOHDZrZ4JPpUTtjoLrUBO/Zu\r\n",
+      "Zbyb9putxys9UURR8WXRteUjG8X/g3u9VOhey5QcrgdB62/kH1BLAQIKAAoAAAAIAD1PfEjhndhx\r\n",
+      "2QEAAHoEAAAvAAAAAAAAAAAAAAAAAAAAAABnb29nbGUuY29tIW5qYWUubWUudWshMTQ1OTAzNjgw\r\n",
+      "MCExNDU5MTIzMTk5LnhtbFBLBQYAAAAAAQABAF0AAAAmAgAAAAA=\r\n",
       "\n"
      ]
     }
      "data": {
       "text/plain": [
        "('OK',\n",
-       " [(b'169 (BODY[1] {986}',\n",
-       "   b'UEsDBAoAAAAIADpKe0gTM/X5EAIAAKsGAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTg5\\r\\nNTA0MDAhMTQ1OTAzNjc5OS54bWzVVU1vnDAQvedXoL0vBrJQqBynp/6C9oy8ZmDdBduyTZL99zVr\\r\\n85FNKkVVpKqnNW9m3swbP1j8+DL00RNow6V42KVxsotAMNlw0T3sfv74vi930SO5wy1Ac6TsTO6i\\r\\nCGtQUtt6AEsbaumEOVTqrhZ0ANJJ2fUQMzlgtIA+BwbKeyKkY+gv+2agmu3NqCa6b9synxdqXqym\\r\\nNZPCUmZrLlpJTtYq8xWhUBqvpYgiKswzaJQdiiIvE8f1tt4TBxm8IVmaJ3malFl1X2VFUmRJitEa\\r\\n9ulOKtSaii6IcdAROi5IesjLKk8OiWvmkTkOopmiVXJffKkqN4qYydBrtqXbdqdYyZ6zS63GY8/N\\r\\nCZZBpNuOIOIXhXiAeDw7Ng/5OG3OfCAaI38IoFHtFZt+PaTcRQjASIVnMwNmRhSzJJ1kTYfrmO+N\\r\\n5BbJpJ6n0/J50W/kqBnUXJEyi9OkitPyELs9rPicyeQoXC+M/GGGQzt4ov3oFtbMgWkL3ChpuHXG\\r\\nDWNvkU3etIPW2cklLOsIetsQWHaykXjT093QLAzzBoTlLXevzVJ2AtqArlsth1c3s8UD0ZtyTEd7\\r\\nqjWYsbcr48204YpZ71bfy0tj/Juyvfng6omGKGrM5Krrw6Jty4k3qj+LfzUXutU0Jc82+YhjsjSL\\r\\niyrO87jI/oFjvL53HOMD/5Fj/vSd+Ay3/D33h5yC0fq/8xtQSwECCgAKAAAACAA6SntIEzP1+RAC\\r\\nAACrBgAALwAAAAAAAAAAAAAAAAAAAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTg5NTA0MDAh\\r\\nMTQ1OTAzNjc5OS54bWxQSwUGAAAAAAEAAQBdAAAAXQIAAAAA\\r\\n'),\n",
+       " [(b'172 (BODY[1] {912}',\n",
+       "   b'UEsDBAoAAAAIAD1PfEjhndhx2QEAAHoEAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTkw\\r\\nMzY4MDAhMTQ1OTEyMzE5OS54bWytVMtyozAQvOcrKN+NEAbW3lKUPeULds+ULAasNUgqSeTx9yss\\r\\n8YiTqlz2hOiZ6ZnuEZCnt6FPXsBYoeTjDqfZLgHJVSNk97j78/t5f9wlT/SBtADNmfErfUgSYkAr\\r\\n4+oBHGuYYxPmUWW6WrIBaKdU10PK1UDQAoYcGJjoqVSeoX/fNwMzfG9HPdH92paFvFjz5gyruZKO\\r\\ncVcL2Sp6cU7bnwjF0nQtRQwxaV/BoLyoqvKYea7P9YE4yhANxRUuDvkxq0pc/sgOZZEXmKA1HvK9\\r\\nVqgNk11U46EzdEJSXJSn7FAdM98tIHMcZHOL4vyATyc/i5zJ0Ee2pdvWVKJVL/h7rcdzL+wFlkGU\\r\\nt0dS+ZdBOkA6Xj1bgEKcNVcxUENQOETQ6vaGTc8Aab8JCQTp+G5nwM6I5o7iSdZ0uI351UjeSa7M\\r\\nPJ1Rr4t+q0bDoRaa5jhPq1NalmmV+wYLPmdyNUpHfSgcZji2gxfWj96wZg5MLgirlRXO39w49hbZ\\r\\n5E0eaGatT1jsiHrbGFg82Ui86+k3NAsjogHpRCv8d7OUXYA1YOrWqOHDZrZ4JPpUTtjoLrUBO/Zu\\r\\nZbyb9putxys9UURR8WXRteUjG8X/g3u9VOhey5QcrgdB62/kH1BLAQIKAAoAAAAIAD1PfEjhndhx\\r\\n2QEAAHoEAAAvAAAAAAAAAAAAAAAAAAAAAABnb29nbGUuY29tIW5qYWUubWUudWshMTQ1OTAzNjgw\\r\\nMCExNDU5MTIzMTk5LnhtbFBLBQYAAAAAAQABAF0AAAAmAgAAAAA=\\r\\n'),\n",
        "  b')'])"
       ]
      },
      "data": {
       "text/plain": [
        "('OK',\n",
-       " [b'169 (BODY (\"application\" \"zip\" (\"name\" \"google.com!njae.me.uk!1458950400!1459036799.zip\") NIL NIL \"base64\" 986))'])"
+       " [b'172 (BODY (\"application\" \"zip\" (\"name\" \"google.com!njae.me.uk!1459036800!1459123199.zip\") NIL NIL \"base64\" 912))'])"
       ]
      },
      "execution_count": 15,
     {
      "data": {
       "text/plain": [
-       "54"
+       "55"
       ]
      },
      "execution_count": 16,
     {
      "data": {
       "text/plain": [
-       "b'Return-Path: <noreply-dmarc-support@google.com>\\r\\nDelivered-To: dmarc@njae.me.uk\\r\\nReceived: from localhost (localhost [127.0.0.1])\\r\\n\\tby mail.njae.me.uk (Postfix) with ESMTP id 2A065106\\r\\n\\tfor <dmarc@njae.me.uk>; Sun, 27 Mar 2016 10:28:09 +0100 (BST)\\r\\nX-Virus-Scanned: Debian amavisd-new at njae.me.uk\\r\\nAuthentication-Results: ogedei.njae.me.uk (amavisd-new);\\r\\n\\tdkim=pass (2048-bit key) header.d=google.com\\r\\nReceived: from mail.njae.me.uk ([127.0.0.1])\\r\\n\\tby localhost (ogedei.njae.me.uk [127.0.0.1]) (amavisd-new, port 10024)\\r\\n\\twith ESMTP id S06rrC9pLQlu for <dmarc@njae.me.uk>;\\r\\n\\tSun, 27 Mar 2016 10:28:07 +0100 (BST)\\r\\nReceived-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.223.201; helo=mail-io0-f201.google.com; envelope-from=noreply-dmarc-support@google.com; receiver=dmarc@njae.me.uk \\r\\nAuthentication-Results: mail.njae.me.uk; dmarc=pass header.from=google.com\\r\\nAuthentication-Results: mail.njae.me.uk; dkim=pass\\r\\n\\treason=\"2048-bit key; unprotected key\"\\r\\n\\theader.d=google.com header.i=@google.com header.b=kRG+/uqj;\\r\\n\\tdkim-adsp=pass; dkim-atps=neutral\\r\\nReceived: from mail-io0-f201.google.com (mail-io0-f201.google.com [209.85.223.201])\\r\\n\\tby mail.njae.me.uk (Postfix) with ESMTPS id 36952EB\\r\\n\\tfor <dmarc@njae.me.uk>; Sun, 27 Mar 2016 10:28:06 +0100 (BST)\\r\\nReceived: by mail-io0-f201.google.com with SMTP id 124so13927004iov.0\\r\\n        for <dmarc@njae.me.uk>; Sun, 27 Mar 2016 02:28:06 -0700 (PDT)\\r\\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\\r\\n        d=google.com; s=20120113;\\r\\n        h=mime-version:message-id:date:subject:from:to:content-disposition\\r\\n         :content-transfer-encoding;\\r\\n        bh=WebWWyH674VepKwkY7+3OEpaPDkuJsYet/WYzuiqEhc=;\\r\\n        b=kRG+/uqjzLNy4IsueOq2bd1CW4i2x4dzf5Dg+soCJzKTycsrUudvIkphybOCPAE4aW\\r\\n         1ffplA6Tt9mxOpAfYppahUPeWFXtCE5AEf3/qorGxcv/yHv8S3TFiUqulTLccOyLbhoG\\r\\n         P02OxDg38XWHLob7gOKUsqdCAmPfxqATsvakVN/SJkJswU4Fm8iBBaoca7wgW/A97eJs\\r\\n         zKnmyWvpc1juUp5YLYWVGwL9927tbw8bO+0acz53Qgwj+QScqSftMNeLzKS3Ct11RkvX\\r\\n         W49XblUJOHS+lbtVF6radeGKbsGp09QClMLAyLKEUeYTTgux/K0CIuB3A+BmQ1O3Souk\\r\\n         cN7A==\\r\\nX-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\\r\\n        d=1e100.net; s=20130820;\\r\\n        h=x-gm-message-state:mime-version:message-id:date:subject:from:to\\r\\n         :content-disposition:content-transfer-encoding;\\r\\n        bh=WebWWyH674VepKwkY7+3OEpaPDkuJsYet/WYzuiqEhc=;\\r\\n        b=iy79Cfu0C9JtwPWMHnqS7hbVnFOcPMPttWMomjdh1ekeq+jxAg9335NteUoNg79PTo\\r\\n         QSJbg9YAM4bvlFPOcPrSNQN+Q5fdopi1TuDBgHK7L0Rb9Vv8eKVRSG8pyLAw7Izs+y/H\\r\\n         9Rlh8qfOV3Te/pzQb+4eA+SS39D9O8L1Cmg2p19Y+XmNfX8xd/UhIKzXNNSbQODMOwnL\\r\\n         xw0wmbMu/3wMgnUgJVfcp7BkZVhJzO7CqNfkGlv4BSpSGEH2+I0AwZFQgLfytwJ4j3nh\\r\\n         oH217zO+us6vAE2gV3zneO4X3Pf88J7ma+I7Et6Bl2cM1TunPpisx6aqnzPdIMhJwMDt\\r\\n         GM+w==\\r\\nX-Gm-Message-State: AD7BkJIXsS+d+n0kHSQlvoPQuXFYd9jWCwS846F7EdDD9cR1K1RkBPs0SrrYY9ARYXU/K7Bs7gdjAw==\\r\\nMIME-Version: 1.0\\r\\nX-Received: by 10.157.11.13 with SMTP id a13mr14086672ota.35.1459070885519;\\r\\n Sun, 27 Mar 2016 02:28:05 -0700 (PDT)\\r\\nMessage-ID: <2150510829392606201@google.com>\\r\\nDate: Sun, 27 Mar 2016 09:28:05 +0000\\r\\nSubject: Report domain: njae.me.uk Submitter: google.com Report-ID: 2150510829392606201\\r\\nFrom: noreply-dmarc-support@google.com\\r\\nTo: dmarc@njae.me.uk\\r\\nContent-Type: application/zip; \\r\\n\\tname=\"google.com!njae.me.uk!1458950400!1459036799.zip\"\\r\\nContent-Disposition: attachment; \\r\\n\\tfilename=\"google.com!njae.me.uk!1458950400!1459036799.zip\"\\r\\nContent-Transfer-Encoding: base64\\r\\n\\r\\nUEsDBAoAAAAIADpKe0gTM/X5EAIAAKsGAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTg5\\r\\nNTA0MDAhMTQ1OTAzNjc5OS54bWzVVU1vnDAQvedXoL0vBrJQqBynp/6C9oy8ZmDdBduyTZL99zVr\\r\\n85FNKkVVpKqnNW9m3swbP1j8+DL00RNow6V42KVxsotAMNlw0T3sfv74vi930SO5wy1Ac6TsTO6i\\r\\nCGtQUtt6AEsbaumEOVTqrhZ0ANJJ2fUQMzlgtIA+BwbKeyKkY+gv+2agmu3NqCa6b9synxdqXqym\\r\\nNZPCUmZrLlpJTtYq8xWhUBqvpYgiKswzaJQdiiIvE8f1tt4TBxm8IVmaJ3malFl1X2VFUmRJitEa\\r\\n9ulOKtSaii6IcdAROi5IesjLKk8OiWvmkTkOopmiVXJffKkqN4qYydBrtqXbdqdYyZ6zS63GY8/N\\r\\nCZZBpNuOIOIXhXiAeDw7Ng/5OG3OfCAaI38IoFHtFZt+PaTcRQjASIVnMwNmRhSzJJ1kTYfrmO+N\\r\\n5BbJpJ6n0/J50W/kqBnUXJEyi9OkitPyELs9rPicyeQoXC+M/GGGQzt4ov3oFtbMgWkL3ChpuHXG\\r\\nDWNvkU3etIPW2cklLOsIetsQWHaykXjT093QLAzzBoTlLXevzVJ2AtqArlsth1c3s8UD0ZtyTEd7\\r\\nqjWYsbcr48204YpZ71bfy0tj/Juyvfng6omGKGrM5Krrw6Jty4k3qj+LfzUXutU0Jc82+YhjsjSL\\r\\niyrO87jI/oFjvL53HOMD/5Fj/vSd+Ay3/D33h5yC0fq/8xtQSwECCgAKAAAACAA6SntIEzP1+RAC\\r\\nAACrBgAALwAAAAAAAAAAAAAAAAAAAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTg5NTA0MDAh\\r\\nMTQ1OTAzNjc5OS54bWxQSwUGAAAAAAEAAQBdAAAAXQIAAAAA\\r\\n'"
+       "b'Return-Path: <noreply-dmarc-support@google.com>\\r\\nDelivered-To: dmarc@njae.me.uk\\r\\nReceived: from localhost (localhost [127.0.0.1])\\r\\n\\tby mail.njae.me.uk (Postfix) with ESMTP id B966C8F\\r\\n\\tfor <dmarc@njae.me.uk>; Mon, 28 Mar 2016 11:11:48 +0100 (BST)\\r\\nX-Virus-Scanned: Debian amavisd-new at njae.me.uk\\r\\nAuthentication-Results: ogedei.njae.me.uk (amavisd-new);\\r\\n\\tdkim=pass (2048-bit key) header.d=google.com\\r\\nReceived: from mail.njae.me.uk ([127.0.0.1])\\r\\n\\tby localhost (ogedei.njae.me.uk [127.0.0.1]) (amavisd-new, port 10024)\\r\\n\\twith ESMTP id GOe6I1LLVNl9 for <dmarc@njae.me.uk>;\\r\\n\\tMon, 28 Mar 2016 11:11:47 +0100 (BST)\\r\\nReceived-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.223.202; helo=mail-io0-f202.google.com; envelope-from=noreply-dmarc-support@google.com; receiver=dmarc@njae.me.uk \\r\\nAuthentication-Results: mail.njae.me.uk; dmarc=pass header.from=google.com\\r\\nAuthentication-Results: mail.njae.me.uk; dkim=pass\\r\\n\\treason=\"2048-bit key; unprotected key\"\\r\\n\\theader.d=google.com header.i=@google.com header.b=FskZAi7J;\\r\\n\\tdkim-adsp=pass; dkim-atps=neutral\\r\\nReceived: from mail-io0-f202.google.com (mail-io0-f202.google.com [209.85.223.202])\\r\\n\\tby mail.njae.me.uk (Postfix) with ESMTPS id CDAA850\\r\\n\\tfor <dmarc@njae.me.uk>; Mon, 28 Mar 2016 11:11:46 +0100 (BST)\\r\\nReceived: by mail-io0-f202.google.com with SMTP id e3so1655636ioa.1\\r\\n        for <dmarc@njae.me.uk>; Mon, 28 Mar 2016 03:11:46 -0700 (PDT)\\r\\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\\r\\n        d=google.com; s=20120113;\\r\\n        h=mime-version:message-id:date:subject:from:to:content-disposition\\r\\n         :content-transfer-encoding;\\r\\n        bh=ZMmMsYb7psOB4wlBTQUv+llYFZLud7uqkJWOqTZoywc=;\\r\\n        b=FskZAi7J5MJ/Py4sgZaL4dHbNcmccPHDWlFnblx0RT0Dlfb35hDkjtYg5ageqyFowe\\r\\n         o4hDspB8+L7cBsY+ftdbMhneveFpKvDgwZqq/88iMOWLuUN39ZWMC7m/XIz2CZhUlLMz\\r\\n         xE25EhSOW9xiWWBOESZzIfCvSOoTuyfxMTUFq1uvARg2NUOAdrFTLTivAsMyK2RNkisM\\r\\n         SrQRcwDaMLIlQw6FzG+gsO3u8wrT6ckd0fHJtkGptab6CqhEwdkY3kJMCmiasoP/io2v\\r\\n         KEsQCkByjHJgnL4tFu5yznLggBrbbvdK4HonSGKDi7cHyuoImxaVZNVMQhaYRnyPqj7j\\r\\n         o08g==\\r\\nX-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\\r\\n        d=1e100.net; s=20130820;\\r\\n        h=x-gm-message-state:mime-version:message-id:date:subject:from:to\\r\\n         :content-disposition:content-transfer-encoding;\\r\\n        bh=ZMmMsYb7psOB4wlBTQUv+llYFZLud7uqkJWOqTZoywc=;\\r\\n        b=OJjK6bq/e//bsrZJ503gIDT0b582UN5hgfMRT+iJVwtH7ombD4ld+S/+NOfWVTwq8J\\r\\n         FoHVodNZjznUtkoOVOm3BFbliMPyxHoYKdbWyYgYH5KzlD9Iv81N5djl50nxdWNkbhK1\\r\\n         CZHike9tfLHF82v6i8BIRMubK8UHyCCOpVgFMM+GK3tTdyA7BY/0jXNqzfTDbS/FyeoW\\r\\n         sH/sckfOf4HN9DRgNbZ78aq5c1bAcx/N7Fn7+53uLBxw82XUd7JFi10kMd3jvPbHMORa\\r\\n         YQgyPoQxuQPvjfU0KTJiXQt+iP+ksHl0DO9umo+c5WzLdHk8QV1ryS5OEhUrfaORqK8a\\r\\n         0d9g==\\r\\nX-Gm-Message-State: AD7BkJLC5599FbOXiJoIKq3UlGXdkIr5BkghJuDHCJeDAQVhAr64/XYgB+fejr5uDj8FvDHPPSPVXA==\\r\\nMIME-Version: 1.0\\r\\nX-Received: by 10.182.243.135 with SMTP id wy7mr16780454obc.8.1459159905131;\\r\\n Mon, 28 Mar 2016 03:11:45 -0700 (PDT)\\r\\nMessage-ID: <16143280651570354241@google.com>\\r\\nDate: Mon, 28 Mar 2016 10:11:45 +0000\\r\\nSubject: Report domain: njae.me.uk Submitter: google.com Report-ID: 16143280651570354241\\r\\nFrom: noreply-dmarc-support@google.com\\r\\nTo: dmarc@njae.me.uk\\r\\nContent-Type: application/zip; \\r\\n\\tname=\"google.com!njae.me.uk!1459036800!1459123199.zip\"\\r\\nContent-Disposition: attachment; \\r\\n\\tfilename=\"google.com!njae.me.uk!1459036800!1459123199.zip\"\\r\\nContent-Transfer-Encoding: base64\\r\\n\\r\\nUEsDBAoAAAAIAD1PfEjhndhx2QEAAHoEAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTkw\\r\\nMzY4MDAhMTQ1OTEyMzE5OS54bWytVMtyozAQvOcrKN+NEAbW3lKUPeULds+ULAasNUgqSeTx9yss\\r\\n8YiTqlz2hOiZ6ZnuEZCnt6FPXsBYoeTjDqfZLgHJVSNk97j78/t5f9wlT/SBtADNmfErfUgSYkAr\\r\\n4+oBHGuYYxPmUWW6WrIBaKdU10PK1UDQAoYcGJjoqVSeoX/fNwMzfG9HPdH92paFvFjz5gyruZKO\\r\\ncVcL2Sp6cU7bnwjF0nQtRQwxaV/BoLyoqvKYea7P9YE4yhANxRUuDvkxq0pc/sgOZZEXmKA1HvK9\\r\\nVqgNk11U46EzdEJSXJSn7FAdM98tIHMcZHOL4vyATyc/i5zJ0Ee2pdvWVKJVL/h7rcdzL+wFlkGU\\r\\nt0dS+ZdBOkA6Xj1bgEKcNVcxUENQOETQ6vaGTc8Aab8JCQTp+G5nwM6I5o7iSdZ0uI351UjeSa7M\\r\\nPJ1Rr4t+q0bDoRaa5jhPq1NalmmV+wYLPmdyNUpHfSgcZji2gxfWj96wZg5MLgirlRXO39w49hbZ\\r\\n5E0eaGatT1jsiHrbGFg82Ui86+k3NAsjogHpRCv8d7OUXYA1YOrWqOHDZrZ4JPpUTtjoLrUBO/Zu\\r\\nZbyb9putxys9UURR8WXRteUjG8X/g3u9VOhey5QcrgdB62/kH1BLAQIKAAoAAAAIAD1PfEjhndhx\\r\\n2QEAAHoEAAAvAAAAAAAAAAAAAAAAAAAAAABnb29nbGUuY29tIW5qYWUubWUudWshMTQ1OTAzNjgw\\r\\nMCExNDU5MTIzMTk5LnhtbFBLBQYAAAAAAQABAF0AAAAmAgAAAAA=\\r\\n'"
       ]
      },
      "execution_count": 18,
     {
      "data": {
       "text/plain": [
-       "<email.message.Message at 0x7f2544346fd0>"
+       "<email.message.Message at 0x7f1bbc67e048>"
       ]
      },
      "execution_count": 19,
     {
      "data": {
       "text/plain": [
-       "<email.message.Message at 0x7f2544351160>"
+       "<email.message.Message at 0x7f1bbc67e390>"
       ]
      },
      "execution_count": 20,
     {
      "data": {
       "text/plain": [
-       "'UEsDBAoAAAAIADpKe0gTM/X5EAIAAKsGAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTg5\\r\\nNTA0MDAhMTQ1OTAzNjc5OS54bWzVVU1vnDAQvedXoL0vBrJQqBynp/6C9oy8ZmDdBduyTZL99zVr\\r\\n85FNKkVVpKqnNW9m3swbP1j8+DL00RNow6V42KVxsotAMNlw0T3sfv74vi930SO5wy1Ac6TsTO6i\\r\\nCGtQUtt6AEsbaumEOVTqrhZ0ANJJ2fUQMzlgtIA+BwbKeyKkY+gv+2agmu3NqCa6b9synxdqXqym\\r\\nNZPCUmZrLlpJTtYq8xWhUBqvpYgiKswzaJQdiiIvE8f1tt4TBxm8IVmaJ3malFl1X2VFUmRJitEa\\r\\n9ulOKtSaii6IcdAROi5IesjLKk8OiWvmkTkOopmiVXJffKkqN4qYydBrtqXbdqdYyZ6zS63GY8/N\\r\\nCZZBpNuOIOIXhXiAeDw7Ng/5OG3OfCAaI38IoFHtFZt+PaTcRQjASIVnMwNmRhSzJJ1kTYfrmO+N\\r\\n5BbJpJ6n0/J50W/kqBnUXJEyi9OkitPyELs9rPicyeQoXC+M/GGGQzt4ov3oFtbMgWkL3ChpuHXG\\r\\nDWNvkU3etIPW2cklLOsIetsQWHaykXjT093QLAzzBoTlLXevzVJ2AtqArlsth1c3s8UD0ZtyTEd7\\r\\nqjWYsbcr48204YpZ71bfy0tj/Juyvfng6omGKGrM5Krrw6Jty4k3qj+LfzUXutU0Jc82+YhjsjSL\\r\\niyrO87jI/oFjvL53HOMD/5Fj/vSd+Ay3/D33h5yC0fq/8xtQSwECCgAKAAAACAA6SntIEzP1+RAC\\r\\nAACrBgAALwAAAAAAAAAAAAAAAAAAAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTg5NTA0MDAh\\r\\nMTQ1OTAzNjc5OS54bWxQSwUGAAAAAAEAAQBdAAAAXQIAAAAA\\r\\n'"
+       "'UEsDBAoAAAAIAD1PfEjhndhx2QEAAHoEAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTkw\\r\\nMzY4MDAhMTQ1OTEyMzE5OS54bWytVMtyozAQvOcrKN+NEAbW3lKUPeULds+ULAasNUgqSeTx9yss\\r\\n8YiTqlz2hOiZ6ZnuEZCnt6FPXsBYoeTjDqfZLgHJVSNk97j78/t5f9wlT/SBtADNmfErfUgSYkAr\\r\\n4+oBHGuYYxPmUWW6WrIBaKdU10PK1UDQAoYcGJjoqVSeoX/fNwMzfG9HPdH92paFvFjz5gyruZKO\\r\\ncVcL2Sp6cU7bnwjF0nQtRQwxaV/BoLyoqvKYea7P9YE4yhANxRUuDvkxq0pc/sgOZZEXmKA1HvK9\\r\\nVqgNk11U46EzdEJSXJSn7FAdM98tIHMcZHOL4vyATyc/i5zJ0Ee2pdvWVKJVL/h7rcdzL+wFlkGU\\r\\nt0dS+ZdBOkA6Xj1bgEKcNVcxUENQOETQ6vaGTc8Aab8JCQTp+G5nwM6I5o7iSdZ0uI351UjeSa7M\\r\\nPJ1Rr4t+q0bDoRaa5jhPq1NalmmV+wYLPmdyNUpHfSgcZji2gxfWj96wZg5MLgirlRXO39w49hbZ\\r\\n5E0eaGatT1jsiHrbGFg82Ui86+k3NAsjogHpRCv8d7OUXYA1YOrWqOHDZrZ4JPpUTtjoLrUBO/Zu\\r\\nZbyb9putxys9UURR8WXRteUjG8X/g3u9VOhey5QcrgdB62/kH1BLAQIKAAoAAAAIAD1PfEjhndhx\\r\\n2QEAAHoEAAAvAAAAAAAAAAAAAAAAAAAAAABnb29nbGUuY29tIW5qYWUubWUudWshMTQ1OTAzNjgw\\r\\nMCExNDU5MTIzMTk5LnhtbFBLBQYAAAAAAQABAF0AAAAmAgAAAAA=\\r\\n'"
       ]
      },
      "execution_count": 22,
     {
      "data": {
       "text/plain": [
-       "b'PK\\x03\\x04\\n\\x00\\x00\\x00\\x08\\x00:J{H\\x133\\xf5\\xf9\\x10\\x02\\x00\\x00\\xab\\x06\\x00\\x00/\\x00\\x00\\x00google.com!njae.me.uk!1458950400!1459036799.xml\\xd5UMo\\x9c0\\x10\\xbd\\xe7W\\xa0\\xbd/\\x06\\xb2P\\xa8\\x1c\\xa7\\xa7\\xfe\\x82\\xf6\\x8c\\xbcf`\\xdd\\x05\\xdb\\xb2M\\x92\\xfd\\xf75k\\xf3\\x91M*EU\\xa4\\xaa\\xa75of\\xde\\xcc\\x1b?X\\xfc\\xf82\\xf4\\xd1\\x13h\\xc3\\xa5x\\xd8\\xa5q\\xb2\\x8b@0\\xd9p\\xd1=\\xec~\\xfe\\xf8\\xbe/w\\xd1#\\xb9\\xc3-@s\\xa4\\xecL\\xee\\xa2\\x08kPR\\xdbz\\x00K\\x1bj\\xe9\\x849T\\xea\\xae\\x16t\\x00\\xd2I\\xd9\\xf5\\x1039`\\xb4\\x80>\\x07\\x06\\xca{\"\\xa4c\\xe8/\\xfbf\\xa0\\x9a\\xed\\xcd\\xa8&\\xbao\\xdb2\\x9f\\x17j^\\xac\\xa65\\x93\\xc2Rfk.ZIN\\xd6*\\xf3\\x15\\xa1P\\x1a\\xaf\\xa5\\x88\"*\\xcc3h\\x94\\x1d\\x8a\"/\\x13\\xc7\\xf5\\xb6\\xde\\x13\\x07\\x19\\xbc!Y\\x9a\\'y\\x9a\\x94Yu_eERdI\\x8a\\xd1\\x1a\\xf6\\xe9N*\\xd4\\x9a\\x8a.\\x88q\\xd0\\x11:.Hz\\xc8\\xcb*O\\x0e\\x89k\\xe6\\x919\\x0e\\xa2\\x99\\xa2Ur_|\\xa9*7\\x8a\\x98\\xc9\\xd0k\\xb6\\xa5\\xdbv\\xa7X\\xc9\\x9e\\xb3K\\xad\\xc6c\\xcf\\xcd\\t\\x96A\\xa4\\xdb\\x8e \\xe2\\x17\\x85x\\x80x<;6\\x0f\\xf98m\\xce| \\x1a#\\x7f\\x08\\xa0Q\\xed\\x15\\x9b~=\\xa4\\xdcE\\x08\\xc0H\\x85g3\\x03fF\\x14\\xb3$\\x9ddM\\x87\\xeb\\x98\\xef\\x8d\\xe4\\x16\\xc9\\xa4\\x9e\\xa7\\xd3\\xf2y\\xd1o\\xe4\\xa8\\x19\\xd4\\\\\\x912\\x8b\\xd3\\xa4\\x8a\\xd3\\xf2\\x10\\xbb=\\xac\\xf8\\x9c\\xc9\\xe4(\\\\/\\x8c\\xfca\\x86C;x\\xa2\\xfd\\xe8\\x16\\xd6\\xcc\\x81i\\x0b\\xdc(i\\xb8u\\xc6\\rco\\x91M\\xde\\xb4\\x83\\xd6\\xd9\\xc9%,\\xeb\\x08z\\xdb\\x10Xv\\xb2\\x91x\\xd3\\xd3\\xdd\\xd0,\\x0c\\xf3\\x06\\x84\\xe5-w\\xaf\\xcdRv\\x02\\xda\\x80\\xae[-\\x87W7\\xb3\\xc5\\x03\\xd1\\x9brLG{\\xaa5\\x98\\xb1\\xb7+\\xe3\\xcd\\xb4\\xe1\\x8aY\\xefV\\xdf\\xcbKc\\xfc\\x9b\\xb2\\xbd\\xf9\\xe0\\xea\\x89\\x86(j\\xcc\\xe4\\xaa\\xeb\\xc3\\xa2m\\xcb\\x897\\xaa?\\x8b\\x7f5\\x17\\xba\\xd54%\\xcf6\\xf9\\x88c\\xb24\\x8b\\x8b*\\xce\\xf3\\xb8\\xc8\\xfe\\x81c\\xbc\\xbew\\x1c\\xe3\\x03\\xff\\x91c\\xfe\\xf4\\x9d\\xf8\\x0c\\xb7\\xfc=\\xf7\\x87\\x9c\\x82\\xd1\\xfa\\xbf\\xf3\\x1bPK\\x01\\x02\\n\\x00\\n\\x00\\x00\\x00\\x08\\x00:J{H\\x133\\xf5\\xf9\\x10\\x02\\x00\\x00\\xab\\x06\\x00\\x00/\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00google.com!njae.me.uk!1458950400!1459036799.xmlPK\\x05\\x06\\x00\\x00\\x00\\x00\\x01\\x00\\x01\\x00]\\x00\\x00\\x00]\\x02\\x00\\x00\\x00\\x00'"
+       "b\"PK\\x03\\x04\\n\\x00\\x00\\x00\\x08\\x00=O|H\\xe1\\x9d\\xd8q\\xd9\\x01\\x00\\x00z\\x04\\x00\\x00/\\x00\\x00\\x00google.com!njae.me.uk!1459036800!1459123199.xml\\xadT\\xcbr\\xa30\\x10\\xbc\\xe7+(\\xdf\\x8d\\x10\\x06\\xd6\\xdeR\\x94=\\xe5\\x0bv\\xcf\\x94,\\x06\\xac5H*I\\xe4\\xf1\\xf7+,\\xf1\\x88\\x93\\xaa\\\\\\xf6\\x84\\xe8\\x99\\xe9\\x99\\xee\\x11\\x90\\xa7\\xb7\\xa1O^\\xc0X\\xa1\\xe4\\xe3\\x0e\\xa7\\xd9.\\x01\\xc9U#d\\xf7\\xb8\\xfb\\xf3\\xfby\\x7f\\xdc%O\\xf4\\x81\\xb4\\x00\\xcd\\x99\\xf1+}H\\x12b@+\\xe3\\xea\\x01\\x1ck\\x98c\\x13\\xe6Qe\\xbaZ\\xb2\\x01h\\xa7T\\xd7C\\xca\\xd5@\\xd0\\x02\\x86\\x1c\\x18\\x98\\xe8\\xa9T\\x9e\\xa1\\x7f\\xdf7\\x033|oG=\\xd1\\xfd\\xda\\x96\\x85\\xbcX\\xf3\\xe6\\x0c\\xab\\xb9\\x92\\x8eqW\\x0b\\xd9*zqN\\xdb\\x9f\\x08\\xc5\\xd2t-E\\x0c1i_\\xc1\\xa0\\xbc\\xa8\\xaa\\xf2\\x98y\\xae\\xcf\\xf5\\x818\\xca\\x10\\r\\xc5\\x15.\\x0e\\xf91\\xabJ\\\\\\xfe\\xc8\\x0ee\\x91\\x17\\x98\\xa05\\x1e\\xf2\\xbdV\\xa8\\r\\x93]T\\xe3\\xa13tBR\\\\\\x94\\xa7\\xecP\\x1d3\\xdf- s\\x1cds\\x8b\\xe2\\xfc\\x80O'?\\x8b\\x9c\\xc9\\xd0G\\xb6\\xa5\\xdb\\xd6T\\xa2U/\\xf8{\\xad\\xc7s/\\xec\\x05\\x96A\\x94\\xb7GR\\xf9\\x97A:@:^=[\\x80B\\x9c5W1PCP8D\\xd0\\xea\\xf6\\x86M\\xcf\\x00i\\xbf\\t\\t\\x04\\xe9\\xf8ng\\xc0\\xce\\x88\\xe6\\x8e\\xe2I\\xd6t\\xb8\\x8d\\xf9\\xd5H\\xdeI\\xae\\xcc<\\x9dQ\\xaf\\x8b~\\xabF\\xc3\\xa1\\x16\\x9a\\xe68O\\xabSZ\\x96i\\x95\\xfb\\x06\\x0b>gr5JG}(\\x1cf8\\xb6\\x83\\x17\\xd6\\x8f\\xde\\xb0f\\x0eL.\\x08\\xab\\x95\\x15\\xce\\xdf\\xdc8\\xf6\\x16\\xd9\\xe4M\\x1ehf\\xadOX\\xec\\x88z\\xdb\\x18X<\\xd9H\\xbc\\xeb\\xe974\\x0b#\\xa2\\x01\\xe9D+\\xfcw\\xb3\\x94]\\x805`\\xea\\xd6\\xa8\\xe1\\xc3f\\xb6x$\\xfaTN\\xd8\\xe8.\\xb5\\x01;\\xf6ne\\xbc\\x9b\\xf6\\x9b\\xad\\xc7+=QDQ\\xf1e\\xd1\\xb5\\xe5#\\x1b\\xc5\\xff\\x83{\\xbdT\\xe8^\\xcb\\x94\\x1c\\xae\\x07A\\xebo\\xe4\\x1fPK\\x01\\x02\\n\\x00\\n\\x00\\x00\\x00\\x08\\x00=O|H\\xe1\\x9d\\xd8q\\xd9\\x01\\x00\\x00z\\x04\\x00\\x00/\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00google.com!njae.me.uk!1459036800!1459123199.xmlPK\\x05\\x06\\x00\\x00\\x00\\x00\\x01\\x00\\x01\\x00]\\x00\\x00\\x00&\\x02\\x00\\x00\\x00\\x00\""
       ]
      },
      "execution_count": 23,
   },
   {
    "cell_type": "code",
-   "execution_count": 135,
+   "execution_count": 24,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 136,
+   "execution_count": 25,
    "metadata": {
     "collapsed": false
    },
     {
      "data": {
       "text/plain": [
-       "'google.com!njae.me.uk!1458950400!1459036799.xml'"
+       "'google.com!njae.me.uk!1459036800!1459123199.xml'"
       ]
      },
-     "execution_count": 136,
+     "execution_count": 25,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 24,
+   "execution_count": 26,
    "metadata": {
     "collapsed": true
    },
    "source": [
     "def walk(node, indent=0):\n",
     "    for child in node:\n",
-    "        print(' '*indent, child.tag, ':', child.text)\n",
+    "        print(' '*indent, child.tag, ':', child.text.strip())\n",
     "        walk(child, indent+2)"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 151,
+   "execution_count": 27,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 25,
+   "execution_count": 28,
    "metadata": {
     "collapsed": false
    },
      "output_type": "stream",
      "text": [
       " report_metadata : \n",
-      "    \n",
       "   org_name : google.com\n",
       "   email : noreply-dmarc-support@google.com\n",
       "   extra_contact_info : https://support.google.com/a/answer/2466580\n",
-      "   report_id : 2150510829392606201\n",
+      "   report_id : 16143280651570354241\n",
       "   date_range : \n",
-      "      \n",
-      "     begin : 1458950400\n",
-      "     end : 1459036799\n",
+      "     begin : 1459036800\n",
+      "     end : 1459123199\n",
       " policy_published : \n",
-      "    \n",
       "   domain : njae.me.uk\n",
       "   adkim : r\n",
       "   aspf : r\n",
       "   sp : none\n",
       "   pct : 100\n",
       " record : \n",
-      "    \n",
-      "   row : \n",
-      "      \n",
-      "     source_ip : 82.109.184.9\n",
-      "     count : 1\n",
-      "     policy_evaluated : \n",
-      "        \n",
-      "       disposition : none\n",
-      "       dkim : fail\n",
-      "       spf : fail\n",
-      "   identifiers : \n",
-      "      \n",
-      "     header_from : njae.me.uk\n",
-      "   auth_results : \n",
-      "      \n",
-      "     dkim : \n",
-      "        \n",
-      "       domain : clublloyds.com\n",
-      "       result : pass\n",
-      "     spf : \n",
-      "        \n",
-      "       domain : clublloyds.com\n",
-      "       result : pass\n",
-      " record : \n",
-      "    \n",
       "   row : \n",
-      "      \n",
       "     source_ip : 212.69.55.62\n",
-      "     count : 1\n",
+      "     count : 2\n",
       "     policy_evaluated : \n",
-      "        \n",
       "       disposition : none\n",
       "       dkim : pass\n",
       "       spf : pass\n",
       "   identifiers : \n",
-      "      \n",
       "     header_from : njae.me.uk\n",
       "   auth_results : \n",
-      "      \n",
       "     dkim : \n",
-      "        \n",
       "       domain : njae.me.uk\n",
       "       result : pass\n",
       "     spf : \n",
-      "        \n",
       "       domain : njae.me.uk\n",
       "       result : pass\n"
      ]
   },
   {
    "cell_type": "code",
-   "execution_count": 26,
+   "execution_count": 29,
    "metadata": {
     "collapsed": false
    },
        "('OK', [b'Close completed.'])"
       ]
      },
-     "execution_count": 26,
+     "execution_count": 29,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 27,
+   "execution_count": 30,
    "metadata": {
     "collapsed": false
    },
        "('BYE', [b'Logging out'])"
       ]
      },
-     "execution_count": 27,
+     "execution_count": 30,
      "metadata": {},
      "output_type": "execute_result"
     }
diff --git a/write-to-database.ipynb b/write-to-database.ipynb
new file mode 100644 (file)
index 0000000..96884af
--- /dev/null
@@ -0,0 +1,1513 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 92,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "import configparser\n",
+    "import xml.etree.ElementTree\n",
+    "import psycopg2\n",
+    "import re\n",
+    "import datetime"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "['dmarc.ini']"
+      ]
+     },
+     "execution_count": 2,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "config = configparser.ConfigParser()\n",
+    "config.read('dmarc.ini')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "['imap', 'database']"
+      ]
+     },
+     "execution_count": 4,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "config.sections()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "['server', 'username', 'port', 'password']"
+      ]
+     },
+     "execution_count": 6,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "[k for k in config['imap']]"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "['server', 'database', 'username', 'password']"
+      ]
+     },
+     "execution_count": 7,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "[k for k in config['database']]"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 25,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "def walk(node, indent=0):\n",
+    "    for child in node:\n",
+    "        if child.text:\n",
+    "            txt = child.text.strip()\n",
+    "        else:\n",
+    "            txt = ''\n",
+    "        print(' '*indent, child.tag, ':', txt)\n",
+    "        walk(child, indent+2)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 16,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "google.com!njae.me.uk!1458777600!1458863999.xml  hotmail.com!njae.me.uk!1459011600!1459098000.xml  yahoo.com!njae.me.uk!1459036800!1459123199.xml\r\n",
+      "google.com!njae.me.uk!1458950400!1459036799.xml  yahoo.com!njae.me.uk!1458864000!1458950399.xml\r\n"
+     ]
+    }
+   ],
+   "source": [
+    "!ls *xml"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 17,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "['google.com!njae.me.uk!1458777600!1458863999.xml',\n",
+       " 'google.com!njae.me.uk!1458950400!1459036799.xml',\n",
+       " 'hotmail.com!njae.me.uk!1459011600!1459098000.xml',\n",
+       " 'yahoo.com!njae.me.uk!1458864000!1458950399.xml',\n",
+       " 'yahoo.com!njae.me.uk!1459036800!1459123199.xml']"
+      ]
+     },
+     "execution_count": 17,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "xmls = !ls *xml\n",
+    "xmls"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 19,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{'google.com!njae.me.uk!1458777600!1458863999.xml': <Element 'feedback' at 0x7fa9a8169a98>,\n",
+       " 'google.com!njae.me.uk!1458950400!1459036799.xml': <Element 'feedback' at 0x7fa9a8170a48>,\n",
+       " 'hotmail.com!njae.me.uk!1459011600!1459098000.xml': <Element 'feedback' at 0x7fa9a80f4a48>,\n",
+       " 'yahoo.com!njae.me.uk!1458864000!1458950399.xml': <Element 'feedback' at 0x7fa9a80f74a8>,\n",
+       " 'yahoo.com!njae.me.uk!1459036800!1459123199.xml': <Element 'feedback' at 0x7fa9a80f7ea8>}"
+      ]
+     },
+     "execution_count": 19,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "dmarc_reports = {f: xml.etree.ElementTree.fromstring(open(f).read()) for f in xmls}\n",
+    "dmarc_reports"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 26,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      " report_metadata : \n",
+      "   org_name : google.com\n",
+      "   email : noreply-dmarc-support@google.com\n",
+      "   extra_contact_info : https://support.google.com/a/answer/2466580\n",
+      "   report_id : 2150510829392606201\n",
+      "   date_range : \n",
+      "     begin : 1458950400\n",
+      "     end : 1459036799\n",
+      " policy_published : \n",
+      "   domain : njae.me.uk\n",
+      "   adkim : r\n",
+      "   aspf : r\n",
+      "   p : none\n",
+      "   sp : none\n",
+      "   pct : 100\n",
+      " record : \n",
+      "   row : \n",
+      "     source_ip : 82.109.184.9\n",
+      "     count : 1\n",
+      "     policy_evaluated : \n",
+      "       disposition : none\n",
+      "       dkim : fail\n",
+      "       spf : fail\n",
+      "   identifiers : \n",
+      "     header_from : njae.me.uk\n",
+      "   auth_results : \n",
+      "     dkim : \n",
+      "       domain : clublloyds.com\n",
+      "       result : pass\n",
+      "     spf : \n",
+      "       domain : clublloyds.com\n",
+      "       result : pass\n",
+      " record : \n",
+      "   row : \n",
+      "     source_ip : 212.69.55.62\n",
+      "     count : 1\n",
+      "     policy_evaluated : \n",
+      "       disposition : none\n",
+      "       dkim : pass\n",
+      "       spf : pass\n",
+      "   identifiers : \n",
+      "     header_from : njae.me.uk\n",
+      "   auth_results : \n",
+      "     dkim : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "     spf : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "\n",
+      " report_metadata : \n",
+      "   org_name : Yahoo! Inc.\n",
+      "   email : postmaster@dmarc.yahoo.com\n",
+      "   report_id : 1459129809.695034\n",
+      "   date_range : \n",
+      "     begin : 1459036800\n",
+      "     end : 1459123199\n",
+      " policy_published : \n",
+      "   domain : njae.me.uk\n",
+      "   adkim : r\n",
+      "   aspf : r\n",
+      "   p : none\n",
+      "   pct : 100\n",
+      " record : \n",
+      "   row : \n",
+      "     source_ip : 65.20.0.12\n",
+      "     count : 1\n",
+      "     policy_evaluated : \n",
+      "       disposition : none\n",
+      "       dkim : pass\n",
+      "       spf : fail\n",
+      "   identifiers : \n",
+      "     header_from : njae.me.uk\n",
+      "   auth_results : \n",
+      "     dkim : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "     spf : \n",
+      "       domain : njae.me.uk\n",
+      "       result : softfail\n",
+      "\n",
+      " report_metadata : \n",
+      "   org_name : Yahoo! Inc.\n",
+      "   email : postmaster@dmarc.yahoo.com\n",
+      "   report_id : 1458957186.548175\n",
+      "   date_range : \n",
+      "     begin : 1458864000\n",
+      "     end : 1458950399\n",
+      " policy_published : \n",
+      "   domain : njae.me.uk\n",
+      "   adkim : r\n",
+      "   aspf : r\n",
+      "   p : none\n",
+      "   pct : 100\n",
+      " record : \n",
+      "   row : \n",
+      "     source_ip : 212.69.55.62\n",
+      "     count : 2\n",
+      "     policy_evaluated : \n",
+      "       disposition : none\n",
+      "       dkim : pass\n",
+      "       spf : pass\n",
+      "   identifiers : \n",
+      "     header_from : njae.me.uk\n",
+      "   auth_results : \n",
+      "     dkim : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "     spf : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "\n",
+      " report_metadata : \n",
+      "   org_name : Microsoft Corp.\n",
+      "   email : dmarcrep@microsoft.com\n",
+      "   report_id : 68aad5080a774e2c997d159b546569b9@hotmail.com\n",
+      "   date_range : \n",
+      "     begin : 1459011600\n",
+      "     end : 1459098000\n",
+      " policy_published : \n",
+      "   domain : njae.me.uk\n",
+      "   adkim : r\n",
+      "   aspf : r\n",
+      "   p : none\n",
+      "   sp : none\n",
+      "   pct : 100\n",
+      " record : \n",
+      "   row : \n",
+      "     source_ip : 212.69.55.62\n",
+      "     count : 2\n",
+      "     policy_evaluated : \n",
+      "       disposition : none\n",
+      "       dkim : pass\n",
+      "       spf : pass\n",
+      "   identifiers : \n",
+      "     header_from : njae.me.uk\n",
+      "   auth_results : \n",
+      "     spf : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "     dkim : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "\n",
+      " report_metadata : \n",
+      "   org_name : google.com\n",
+      "   email : noreply-dmarc-support@google.com\n",
+      "   extra_contact_info : https://support.google.com/a/answer/2466580\n",
+      "   report_id : 13032699446207263761\n",
+      "   date_range : \n",
+      "     begin : 1458777600\n",
+      "     end : 1458863999\n",
+      " policy_published : \n",
+      "   domain : njae.me.uk\n",
+      "   adkim : r\n",
+      "   aspf : r\n",
+      "   p : none\n",
+      "   sp : none\n",
+      "   pct : 100\n",
+      " record : \n",
+      "   row : \n",
+      "     source_ip : 146.185.136.235\n",
+      "     count : 1\n",
+      "     policy_evaluated : \n",
+      "       disposition : none\n",
+      "       dkim : pass\n",
+      "       spf : fail\n",
+      "   identifiers : \n",
+      "     header_from : njae.me.uk\n",
+      "   auth_results : \n",
+      "     dkim : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "     spf : \n",
+      "       domain : njae.me.uk\n",
+      "       result : softfail\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "for f in dmarc_reports:\n",
+    "    walk(dmarc_reports[f])\n",
+    "    print()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      " report_metadata : \n",
+      "   org_name : Yahoo! Inc.\n",
+      "   email : postmaster@dmarc.yahoo.com\n",
+      "   report_id : 1459129809.695034\n",
+      "   date_range : \n",
+      "     begin : 1459036800\n",
+      "     end : 1459123199\n",
+      " policy_published : \n",
+      "   domain : njae.me.uk\n",
+      "   adkim : r\n",
+      "   aspf : r\n",
+      "   p : none\n",
+      "   pct : 100\n",
+      " record : \n",
+      "   row : \n",
+      "     source_ip : 65.20.0.12\n",
+      "     count : 1\n",
+      "     policy_evaluated : \n",
+      "       disposition : none\n",
+      "       dkim : pass\n",
+      "       spf : fail\n",
+      "   identifiers : \n",
+      "     header_from : njae.me.uk\n",
+      "   auth_results : \n",
+      "     dkim : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "     spf : \n",
+      "       domain : njae.me.uk\n",
+      "       result : softfail\n"
+     ]
+    }
+   ],
+   "source": [
+    "root2 = xml.etree.ElementTree.fromstring(open('yahoo.com!njae.me.uk!1459036800!1459123199.xml').read())\n",
+    "walk(root2)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 28,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "conn = psycopg2.connect(host=config['database']['server'],\n",
+    "                        database=config['database']['database'], \n",
+    "                        user=config['database']['username'], \n",
+    "                        password=config['database']['password'])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 30,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "<cursor object at 0x7fa9a819b7c8; closed: 0>"
+      ]
+     },
+     "execution_count": 30,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "cur = conn.cursor()\n",
+    "cur"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 31,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{'email': 'varchar', 'org_name': 'varchar', 'report_id': 'varchar'}"
+      ]
+     },
+     "execution_count": 31,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "report_fields = {'date_range_begin': 'timestamp', 'date_range_end': 'timestamp'}\n",
+    "for child in root2:\n",
+    "    if child.tag == 'report_metadata':\n",
+    "        for c in child:\n",
+    "            if c.tag != 'date_range':\n",
+    "                report_fields[c.tag] = 'varchar'\n",
+    "report_fields"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 65,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "def xpath_of(node, prefix=''):\n",
+    "    if len(node) == 0:\n",
+    "        if node.text:\n",
+    "            nodes = {prefix + node.tag: node.text.strip()}\n",
+    "        else:\n",
+    "            nodes = {prefix + node.tag: ''}\n",
+    "    else:\n",
+    "        nodes = {}\n",
+    "    if node:\n",
+    "        for child in node:\n",
+    "            nodes.update(xpath_of(child, \n",
+    "                                  prefix + node.tag + '/'))\n",
+    "    return nodes"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 66,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{'feedback/policy_published/adkim': 'r',\n",
+       " 'feedback/policy_published/aspf': 'r',\n",
+       " 'feedback/policy_published/domain': 'njae.me.uk',\n",
+       " 'feedback/policy_published/p': 'none',\n",
+       " 'feedback/policy_published/pct': '100',\n",
+       " 'feedback/record/auth_results/dkim/domain': 'njae.me.uk',\n",
+       " 'feedback/record/auth_results/dkim/result': 'pass',\n",
+       " 'feedback/record/auth_results/spf/domain': 'njae.me.uk',\n",
+       " 'feedback/record/auth_results/spf/result': 'softfail',\n",
+       " 'feedback/record/identifiers/header_from': 'njae.me.uk',\n",
+       " 'feedback/record/row/count': '1',\n",
+       " 'feedback/record/row/policy_evaluated/disposition': 'none',\n",
+       " 'feedback/record/row/policy_evaluated/dkim': 'pass',\n",
+       " 'feedback/record/row/policy_evaluated/spf': 'fail',\n",
+       " 'feedback/record/row/source_ip': '65.20.0.12',\n",
+       " 'feedback/report_metadata/date_range/begin': '1459036800',\n",
+       " 'feedback/report_metadata/date_range/end': '1459123199',\n",
+       " 'feedback/report_metadata/email': 'postmaster@dmarc.yahoo.com',\n",
+       " 'feedback/report_metadata/org_name': 'Yahoo! Inc.',\n",
+       " 'feedback/report_metadata/report_id': '1459129809.695034'}"
+      ]
+     },
+     "execution_count": 66,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "xpath_of(root2)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 63,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'1459036800'"
+      ]
+     },
+     "execution_count": 63,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "root2.find('./report_metadata/date_range/begin').text"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 77,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'./report_metadata/date_range/begin'"
+      ]
+     },
+     "execution_count": 77,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "re.sub(r'^\\w*(/.*)$', r'.\\1', 'feedback/report_metadata/date_range/begin')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 82,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'report_metadata_date_range_begin'"
+      ]
+     },
+     "execution_count": 82,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "re.sub(r'/', r'_',\n",
+    "       re.sub(r'^[^\\/]*/(.*)$', r'\\1', 'feedback/report_metadata/date_range/begin'))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 156,
+   "metadata": {
+    "collapsed": false,
+    "scrolled": true
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{'./policy_published/adkim': {'pg_field_name': 'policy_published_adkim',\n",
+       "  'pg_table': 'reports',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './policy_published/aspf': {'pg_field_name': 'policy_published_aspf',\n",
+       "  'pg_table': 'reports',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './policy_published/domain': {'pg_field_name': 'policy_published_domain',\n",
+       "  'pg_table': 'reports',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './policy_published/p': {'pg_field_name': 'policy_published_p',\n",
+       "  'pg_table': 'reports',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './policy_published/pct': {'pg_field_name': 'policy_published_pct',\n",
+       "  'pg_table': 'reports',\n",
+       "  'pg_type': 'int'},\n",
+       " './record[{}]/auth_results/dkim/domain': {'pg_field_name': 'auth_results_dkim_domain',\n",
+       "  'pg_table': 'report_items',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './record[{}]/auth_results/dkim/result': {'pg_field_name': 'auth_results_dkim_result',\n",
+       "  'pg_table': 'report_items',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './record[{}]/auth_results/spf/domain': {'pg_field_name': 'auth_results_spf_domain',\n",
+       "  'pg_table': 'report_items',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './record[{}]/auth_results/spf/result': {'pg_field_name': 'auth_results_spf_result',\n",
+       "  'pg_table': 'report_items',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './record[{}]/identifiers/header_from': {'pg_field_name': 'identifiers_header_from',\n",
+       "  'pg_table': 'report_items',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './record[{}]/row/count': {'pg_field_name': 'count',\n",
+       "  'pg_table': 'report_items',\n",
+       "  'pg_type': 'int'},\n",
+       " './record[{}]/row/policy_evaluated/disposition': {'pg_field_name': 'policy_evaluated_disposition',\n",
+       "  'pg_table': 'report_items',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './record[{}]/row/policy_evaluated/dkim': {'pg_field_name': 'policy_evaluated_dkim',\n",
+       "  'pg_table': 'report_items',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './record[{}]/row/policy_evaluated/spf': {'pg_field_name': 'policy_evaluated_spf',\n",
+       "  'pg_table': 'report_items',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './record[{}]/row/source_ip': {'pg_field_name': 'source_ip',\n",
+       "  'pg_table': 'report_items',\n",
+       "  'pg_type': 'inet'},\n",
+       " './report_metadata/date_range/begin': {'pg_field_name': 'report_metadata_date_range_begin',\n",
+       "  'pg_table': 'reports',\n",
+       "  'pg_type': 'timestamp'},\n",
+       " './report_metadata/date_range/end': {'pg_field_name': 'report_metadata_date_range_end',\n",
+       "  'pg_table': 'reports',\n",
+       "  'pg_type': 'timestamp'},\n",
+       " './report_metadata/email': {'pg_field_name': 'report_metadata_email',\n",
+       "  'pg_table': 'reports',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './report_metadata/org_name': {'pg_field_name': 'report_metadata_org_name',\n",
+       "  'pg_table': 'reports',\n",
+       "  'pg_type': 'varchar'},\n",
+       " './report_metadata/report_id': {'pg_field_name': 'report_metadata_report_id',\n",
+       "  'pg_table': 'reports',\n",
+       "  'pg_type': 'varchar'}}"
+      ]
+     },
+     "execution_count": 156,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "field_maps = {re.sub(r'^\\w*(/.*)$', r'.\\1', name): \n",
+    "              {'pg_field_name': re.sub(r'/', r'_', re.sub(r'^[^\\/]*/(.*)$', r'\\1', name)),\n",
+    "              'pg_table': 'reports',\n",
+    "              'pg_type': 'varchar'}\n",
+    "             for name in xpath_of(root2)\n",
+    "             if 'record' not in name}\n",
+    "field_maps.update({re.sub(r'^\\w*/record(/.*)$', r'./record[{}]\\1', name): \n",
+    "              {'pg_field_name': re.sub(r'/', r'_', re.sub(r'^.*/record(/row)?/(.*)$', r'\\2', name)),\n",
+    "              'pg_table': 'report_items',\n",
+    "              'pg_type': 'varchar'}\n",
+    "             for name in xpath_of(root2)\n",
+    "             if 'record' in name})\n",
+    "field_maps['./report_metadata/date_range/begin']['pg_type'] = 'timestamp'\n",
+    "field_maps['./report_metadata/date_range/end']['pg_type'] = 'timestamp'\n",
+    "field_maps['./policy_published/pct']['pg_type'] = 'int'\n",
+    "field_maps['./record[{}]/row/count']['pg_type'] = 'int'\n",
+    "field_maps['./record[{}]/row/source_ip']['pg_type'] = 'inet'\n",
+    "\n",
+    "field_maps"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 95,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "datetime.datetime(2016, 3, 27, 23, 59, 59)"
+      ]
+     },
+     "execution_count": 95,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "datetime.datetime.utcfromtimestamp(1459123199)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 100,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "1459119599.0"
+      ]
+     },
+     "execution_count": 100,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "datetime.datetime.utcfromtimestamp(1459123199).timestamp()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 157,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'create table reports (id serial primary key, policy_published_p varchar, report_metadata_date_range_end timestamp, report_metadata_org_name varchar, policy_published_aspf varchar, policy_published_adkim varchar, policy_published_pct int, report_metadata_email varchar, report_metadata_date_range_begin timestamp, report_metadata_report_id varchar, policy_published_domain varchar);'"
+      ]
+     },
+     "execution_count": 157,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "create_report_table_string = 'create table reports (id serial primary key, ' + \\\n",
+    "', '.join(field_maps[p]['pg_field_name'] + ' ' + field_maps[p]['pg_type'] \n",
+    " for p in field_maps if field_maps[p]['pg_table'] == 'reports') + \\\n",
+    "');'\n",
+    "create_report_table_string"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 193,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'create table report_items (id serial primary key, report_id integer references reports, auth_results_spf_domain varchar, auth_results_dkim_domain varchar, policy_evaluated_dkim varchar, auth_results_spf_result varchar, source_ip inet, policy_evaluated_spf varchar, count int, identifiers_header_from varchar, policy_evaluated_disposition varchar, auth_results_dkim_result varchar);'"
+      ]
+     },
+     "execution_count": 193,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "create_report_item_table_string = 'create table report_items (id serial primary key, ' + \\\n",
+    "  'report_id integer references reports, ' + \\\n",
+    "', '.join(field_maps[p]['pg_field_name'] + ' ' + field_maps[p]['pg_type'] \n",
+    " for p in field_maps if field_maps[p]['pg_table'] == 'report_items') + \\\n",
+    "');'\n",
+    "create_report_item_table_string"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 117,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "<cursor object at 0x7fa9a819b7c8; closed: 0>"
+      ]
+     },
+     "execution_count": 117,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "cur"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 194,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "cur.execute(create_report_table_string)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 195,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "cur.execute(create_report_item_table_string)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 196,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "conn.commit()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 128,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "rep = dmarc_reports['google.com!njae.me.uk!1458777600!1458863999.xml']"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 134,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'1'"
+      ]
+     },
+     "execution_count": 134,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "rep.find('./record/row/count').text"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 135,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[('google.com!njae.me.uk!1458950400!1459036799.xml', '1'),\n",
+       " ('yahoo.com!njae.me.uk!1459036800!1459123199.xml', '1'),\n",
+       " ('yahoo.com!njae.me.uk!1458864000!1458950399.xml', '2'),\n",
+       " ('hotmail.com!njae.me.uk!1459011600!1459098000.xml', '2'),\n",
+       " ('google.com!njae.me.uk!1458777600!1458863999.xml', '1')]"
+      ]
+     },
+     "execution_count": 135,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "[(r, dmarc_reports[r].find('./record/row/count').text) for r in dmarc_reports]"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 136,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      " report_metadata : \n",
+      "   org_name : Microsoft Corp.\n",
+      "   email : dmarcrep@microsoft.com\n",
+      "   report_id : 68aad5080a774e2c997d159b546569b9@hotmail.com\n",
+      "   date_range : \n",
+      "     begin : 1459011600\n",
+      "     end : 1459098000\n",
+      " policy_published : \n",
+      "   domain : njae.me.uk\n",
+      "   adkim : r\n",
+      "   aspf : r\n",
+      "   p : none\n",
+      "   sp : none\n",
+      "   pct : 100\n",
+      " record : \n",
+      "   row : \n",
+      "     source_ip : 212.69.55.62\n",
+      "     count : 2\n",
+      "     policy_evaluated : \n",
+      "       disposition : none\n",
+      "       dkim : pass\n",
+      "       spf : pass\n",
+      "   identifiers : \n",
+      "     header_from : njae.me.uk\n",
+      "   auth_results : \n",
+      "     spf : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "     dkim : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n"
+     ]
+    }
+   ],
+   "source": [
+    "walk(dmarc_reports['hotmail.com!njae.me.uk!1459011600!1459098000.xml'])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 137,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      " report_metadata : \n",
+      "   org_name : google.com\n",
+      "   email : noreply-dmarc-support@google.com\n",
+      "   extra_contact_info : https://support.google.com/a/answer/2466580\n",
+      "   report_id : 2150510829392606201\n",
+      "   date_range : \n",
+      "     begin : 1458950400\n",
+      "     end : 1459036799\n",
+      " policy_published : \n",
+      "   domain : njae.me.uk\n",
+      "   adkim : r\n",
+      "   aspf : r\n",
+      "   p : none\n",
+      "   sp : none\n",
+      "   pct : 100\n",
+      " record : \n",
+      "   row : \n",
+      "     source_ip : 82.109.184.9\n",
+      "     count : 1\n",
+      "     policy_evaluated : \n",
+      "       disposition : none\n",
+      "       dkim : fail\n",
+      "       spf : fail\n",
+      "   identifiers : \n",
+      "     header_from : njae.me.uk\n",
+      "   auth_results : \n",
+      "     dkim : \n",
+      "       domain : clublloyds.com\n",
+      "       result : pass\n",
+      "     spf : \n",
+      "       domain : clublloyds.com\n",
+      "       result : pass\n",
+      " record : \n",
+      "   row : \n",
+      "     source_ip : 212.69.55.62\n",
+      "     count : 1\n",
+      "     policy_evaluated : \n",
+      "       disposition : none\n",
+      "       dkim : pass\n",
+      "       spf : pass\n",
+      "   identifiers : \n",
+      "     header_from : njae.me.uk\n",
+      "   auth_results : \n",
+      "     dkim : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n",
+      "     spf : \n",
+      "       domain : njae.me.uk\n",
+      "       result : pass\n"
+     ]
+    }
+   ],
+   "source": [
+    "walk(dmarc_reports['google.com!njae.me.uk!1458950400!1459036799.xml'])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 159,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "['./record[{}]/auth_results/spf/domain',\n",
+       " './record[{}]/auth_results/dkim/domain',\n",
+       " './record[{}]/row/policy_evaluated/dkim',\n",
+       " './record[{}]/auth_results/spf/result',\n",
+       " './record[{}]/row/source_ip',\n",
+       " './record[{}]/row/policy_evaluated/spf',\n",
+       " './record[{}]/row/count',\n",
+       " './record[{}]/identifiers/header_from',\n",
+       " './record[{}]/row/policy_evaluated/disposition',\n",
+       " './record[{}]/auth_results/dkim/result']"
+      ]
+     },
+     "execution_count": 159,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "[p for p in field_maps if field_maps[p]['pg_table'] == 'report_items']"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 140,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "2"
+      ]
+     },
+     "execution_count": 140,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "len(dmarc_reports['google.com!njae.me.uk!1458950400!1459036799.xml'].findall('./record'))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 144,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'212.69.55.62'"
+      ]
+     },
+     "execution_count": 144,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "dmarc_reports['google.com!njae.me.uk!1458950400!1459036799.xml'].find('./record[2]/row/source_ip').text"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 153,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'82.109.184.9'"
+      ]
+     },
+     "execution_count": 153,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "dmarc_reports['google.com!njae.me.uk!1458950400!1459036799.xml'].find('./record[{}]/row/source_ip'.format(1)).text"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 163,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "policy_published_p :> none\n",
+      "report_metadata_date_range_end :> 1459036799\n",
+      "report_metadata_org_name :> google.com\n",
+      "policy_published_aspf :> r\n",
+      "policy_published_adkim :> r\n",
+      "policy_published_pct :> 100\n",
+      "report_metadata_email :> noreply-dmarc-support@google.com\n",
+      "report_metadata_date_range_begin :> 1458950400\n",
+      "report_metadata_report_id :> 2150510829392606201\n",
+      "policy_published_domain :> njae.me.uk\n"
+     ]
+    }
+   ],
+   "source": [
+    "rep = dmarc_reports['google.com!njae.me.uk!1458950400!1459036799.xml']\n",
+    "for f in [f for f in field_maps if field_maps[f]['pg_table'] == 'reports']:\n",
+    "    print(field_maps[f]['pg_field_name'], ':>', rep.find(f).text)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 165,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "1\n",
+      "auth_results_spf_domain :> clublloyds.com\n",
+      "auth_results_dkim_domain :> clublloyds.com\n",
+      "policy_evaluated_dkim :> fail\n",
+      "auth_results_spf_result :> pass\n",
+      "source_ip :> 82.109.184.9\n",
+      "policy_evaluated_spf :> fail\n",
+      "count :> 1\n",
+      "identifiers_header_from :> njae.me.uk\n",
+      "policy_evaluated_disposition :> none\n",
+      "auth_results_dkim_result :> pass\n",
+      "2\n",
+      "auth_results_spf_domain :> njae.me.uk\n",
+      "auth_results_dkim_domain :> njae.me.uk\n",
+      "policy_evaluated_dkim :> pass\n",
+      "auth_results_spf_result :> pass\n",
+      "source_ip :> 212.69.55.62\n",
+      "policy_evaluated_spf :> pass\n",
+      "count :> 1\n",
+      "identifiers_header_from :> njae.me.uk\n",
+      "policy_evaluated_disposition :> none\n",
+      "auth_results_dkim_result :> pass\n"
+     ]
+    }
+   ],
+   "source": [
+    "rep = dmarc_reports['google.com!njae.me.uk!1458950400!1459036799.xml']\n",
+    "for i in range(1, len(rep.findall('./record'))+1):\n",
+    "    print(i)\n",
+    "    for f in [f for f in field_maps if field_maps[f]['pg_table'] == 'report_items']:\n",
+    "        print(field_maps[f]['pg_field_name'], ':>', rep.find(f.format(i)).text)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 166,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "def maybe_strip(text):\n",
+    "    if text:\n",
+    "        return text.strip()\n",
+    "    else:\n",
+    "        return ''"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 197,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "('insert into reports (policy_published_p, report_metadata_date_range_end, report_metadata_org_name, policy_published_aspf, policy_published_adkim, policy_published_pct, report_metadata_email, report_metadata_date_range_begin, report_metadata_report_id, policy_published_domain) values (%(policy_published_p)s, %(report_metadata_date_range_end)s, %(report_metadata_org_name)s, %(policy_published_aspf)s, %(policy_published_adkim)s, %(policy_published_pct)s, %(report_metadata_email)s, %(report_metadata_date_range_begin)s, %(report_metadata_report_id)s, %(policy_published_domain)s);',\n",
+       " {'policy_published_adkim': 'r',\n",
+       "  'policy_published_aspf': 'r',\n",
+       "  'policy_published_domain': 'njae.me.uk',\n",
+       "  'policy_published_p': 'none',\n",
+       "  'policy_published_pct': 100,\n",
+       "  'report_metadata_date_range_begin': datetime.datetime(2016, 3, 26, 0, 0),\n",
+       "  'report_metadata_date_range_end': datetime.datetime(2016, 3, 26, 23, 59, 59),\n",
+       "  'report_metadata_email': 'noreply-dmarc-support@google.com',\n",
+       "  'report_metadata_org_name': 'google.com',\n",
+       "  'report_metadata_report_id': '2150510829392606201'})"
+      ]
+     },
+     "execution_count": 197,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "rep = dmarc_reports['google.com!njae.me.uk!1458950400!1459036799.xml']\n",
+    "field_names = []\n",
+    "values = {}\n",
+    "for f in [f for f in field_maps if field_maps[f]['pg_table'] == 'reports']:\n",
+    "    field_names += [field_maps[f]['pg_field_name']]\n",
+    "    if field_maps[f]['pg_type'] == 'int':\n",
+    "        values[field_maps[f]['pg_field_name']] = int(rep.find(f).text)\n",
+    "    elif field_maps[f]['pg_type'] == 'timestamp':\n",
+    "        values[field_maps[f]['pg_field_name']] = datetime.datetime.utcfromtimestamp(int(rep.find(f).text))\n",
+    "    elif field_maps[f]['pg_type'] == 'inet':\n",
+    "        values[field_maps[f]['pg_field_name']] = maybe_strip(rep.find(f).text)\n",
+    "    else:\n",
+    "        values[field_maps[f]['pg_field_name']] = maybe_strip(rep.find(f).text)\n",
+    "insert_string = 'insert into reports (' + ', '.join(field_names) +') '\n",
+    "insert_string += 'values (' + ', '.join('%({})s'.format(f) for f in field_names) + ');'\n",
+    "insert_string, values"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 198,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "cur.execute(insert_string, values)\n",
+    "conn.commit()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 201,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "1"
+      ]
+     },
+     "execution_count": 201,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "cur.execute('select id, report_metadata_report_id from reports where report_metadata_report_id = %s;', \n",
+    "            [rep.find('./report_metadata/report_id').text])\n",
+    "cur.fetchall()[0][0]"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 203,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "1\n",
+      "insert into report_items (report_id, auth_results_spf_domain, auth_results_dkim_domain, policy_evaluated_dkim, auth_results_spf_result, source_ip, policy_evaluated_spf, count, identifiers_header_from, policy_evaluated_disposition, auth_results_dkim_result) values (%(report_id)s, %(auth_results_spf_domain)s, %(auth_results_dkim_domain)s, %(policy_evaluated_dkim)s, %(auth_results_spf_result)s, %(source_ip)s, %(policy_evaluated_spf)s, %(count)s, %(identifiers_header_from)s, %(policy_evaluated_disposition)s, %(auth_results_dkim_result)s); {'auth_results_spf_result': 'pass', 'count': 1, 'report_id': 1, 'identifiers_header_from': 'njae.me.uk', 'policy_evaluated_disposition': 'none', 'auth_results_dkim_result': 'pass', 'source_ip': '82.109.184.9', 'policy_evaluated_spf': 'fail', 'auth_results_dkim_domain': 'clublloyds.com', 'auth_results_spf_domain': 'clublloyds.com', 'policy_evaluated_dkim': 'fail'}\n",
+      "2\n",
+      "insert into report_items (report_id, auth_results_spf_domain, auth_results_dkim_domain, policy_evaluated_dkim, auth_results_spf_result, source_ip, policy_evaluated_spf, count, identifiers_header_from, policy_evaluated_disposition, auth_results_dkim_result) values (%(report_id)s, %(auth_results_spf_domain)s, %(auth_results_dkim_domain)s, %(policy_evaluated_dkim)s, %(auth_results_spf_result)s, %(source_ip)s, %(policy_evaluated_spf)s, %(count)s, %(identifiers_header_from)s, %(policy_evaluated_disposition)s, %(auth_results_dkim_result)s); {'auth_results_spf_result': 'pass', 'count': 1, 'report_id': 1, 'identifiers_header_from': 'njae.me.uk', 'policy_evaluated_disposition': 'none', 'auth_results_dkim_result': 'pass', 'source_ip': '212.69.55.62', 'policy_evaluated_spf': 'pass', 'auth_results_dkim_domain': 'njae.me.uk', 'auth_results_spf_domain': 'njae.me.uk', 'policy_evaluated_dkim': 'pass'}\n"
+     ]
+    }
+   ],
+   "source": [
+    "rep = dmarc_reports['google.com!njae.me.uk!1458950400!1459036799.xml']\n",
+    "for i in range(1, len(rep.findall('./record'))+1):\n",
+    "    print(i)\n",
+    "    field_names = []\n",
+    "    cur.execute('select id, report_metadata_report_id from reports where report_metadata_report_id = %s;', \n",
+    "            [rep.find('./report_metadata/report_id').text])\n",
+    "    results = cur.fetchall()\n",
+    "    if len(results) != 1:\n",
+    "        raise\n",
+    "    else:\n",
+    "        report_id = results[0][0]\n",
+    "    values = {'report_id': report_id}\n",
+    "    for f in [f for f in field_maps if field_maps[f]['pg_table'] == 'report_items']:\n",
+    "        field_names += [field_maps[f]['pg_field_name']]\n",
+    "        if field_maps[f]['pg_type'] == 'int':\n",
+    "            values[field_maps[f]['pg_field_name']] = int(rep.find(f.format(i)).text)\n",
+    "        elif field_maps[f]['pg_type'] == 'timestamp':\n",
+    "            values[field_maps[f]['pg_field_name']] = datetime.datetime.utcfromtimestamp(int(rep.find(f.format(i)).text))\n",
+    "        elif field_maps[f]['pg_type'] == 'inet':\n",
+    "            values[field_maps[f]['pg_field_name']] = maybe_strip(rep.find(f.format(i)).text)\n",
+    "        else:\n",
+    "            values[field_maps[f]['pg_field_name']] = maybe_strip(rep.find(f.format(i)).text)\n",
+    "    insert_string = 'insert into report_items (report_id, ' + ', '.join(field_names) +') '\n",
+    "    insert_string += 'values (%(report_id)s, ' + ', '.join('%({})s'.format(f) for f in field_names) + ');'\n",
+    "    print(insert_string, values)\n",
+    "    cur.execute(insert_string, values)\n",
+    "conn.commit()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 191,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "conn.rollback()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 209,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "def write_report(connection, cursor, report):\n",
+    "    \n",
+    "    field_names = []\n",
+    "    values = {}\n",
+    "    for f in [f for f in field_maps if field_maps[f]['pg_table'] == 'reports']:\n",
+    "        field_names += [field_maps[f]['pg_field_name']]\n",
+    "        if field_maps[f]['pg_type'] == 'int':\n",
+    "            values[field_maps[f]['pg_field_name']] = int(report.find(f).text)\n",
+    "        elif field_maps[f]['pg_type'] == 'timestamp':\n",
+    "            values[field_maps[f]['pg_field_name']] = datetime.datetime.utcfromtimestamp(int(report.find(f).text))\n",
+    "        elif field_maps[f]['pg_type'] == 'inet':\n",
+    "            values[field_maps[f]['pg_field_name']] = maybe_strip(report.find(f).text)\n",
+    "        else:\n",
+    "            values[field_maps[f]['pg_field_name']] = maybe_strip(report.find(f).text)\n",
+    "    insert_string = 'insert into reports (' + ', '.join(field_names) + ') '\n",
+    "    insert_string += 'values (' + ', '.join('%({})s'.format(f) for f in field_names) + ');'\n",
+    "    cursor.execute(insert_string, values)\n",
+    "    \n",
+    "    for i in range(1, len(report.findall('./record'))+1):\n",
+    "        field_names = []\n",
+    "        cursor.execute('select id, report_metadata_report_id from reports where report_metadata_report_id = %s;', \n",
+    "            [report.find('./report_metadata/report_id').text])\n",
+    "        results = cursor.fetchall()\n",
+    "        if len(results) != 1:\n",
+    "            raise\n",
+    "        else:\n",
+    "            report_id = results[0][0]\n",
+    "        values = {'report_id': report_id}\n",
+    "        for f in [f for f in field_maps if field_maps[f]['pg_table'] == 'report_items']:\n",
+    "            field_names += [field_maps[f]['pg_field_name']]\n",
+    "            if field_maps[f]['pg_type'] == 'int':\n",
+    "                values[field_maps[f]['pg_field_name']] = int(report.find(f.format(i)).text)\n",
+    "            elif field_maps[f]['pg_type'] == 'timestamp':\n",
+    "                values[field_maps[f]['pg_field_name']] = datetime.datetime.utcfromtimestamp(int(report.find(f.format(i)).text))\n",
+    "            elif field_maps[f]['pg_type'] == 'inet':\n",
+    "                values[field_maps[f]['pg_field_name']] = maybe_strip(report.find(f.format(i)).text)\n",
+    "            else:\n",
+    "                values[field_maps[f]['pg_field_name']] = maybe_strip(report.find(f.format(i)).text)\n",
+    "        insert_string = 'insert into report_items (report_id, ' + ', '.join(field_names) + ') '\n",
+    "        insert_string += 'values (%(report_id)s, ' + ', '.join('%({})s'.format(f) for f in field_names) + ');'\n",
+    "        cursor.execute(insert_string, values)\n",
+    "    connection.commit()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 210,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "for rep in dmarc_reports:\n",
+    "    write_report(conn, cur, dmarc_reports[rep])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 211,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "conn.close()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 208,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "conn.rollback()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.4.3+"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}