11 "import configparser\n",
15 "# import email.parser\n",
19 "import xml.etree.ElementTree"
37 "output_type": "execute_result"
41 "config = configparser.ConfigParser()\n",
42 "config.read('dmarc.ini')"
60 "output_type": "execute_result"
64 "[k for k in config['DEFAULT']]"
69 "execution_count": 31,
77 "['imap', 'database']"
80 "execution_count": 31,
82 "output_type": "execute_result"
102 "execution_count": 4,
104 "output_type": "execute_result"
108 "config['imap']['server']"
113 "execution_count": 5,
119 "mailbox = imaplib.IMAP4(host=config['imap']['server'], \n",
120 " port=config['imap']['port'])"
125 "execution_count": 6,
136 "execution_count": 6,
138 "output_type": "execute_result"
147 "execution_count": 7,
155 "('OK', [b'Logged in'])"
158 "execution_count": 7,
160 "output_type": "execute_result"
164 "mailbox.login(config['imap']['username'], config['imap']['password'])"
169 "execution_count": 8,
180 "execution_count": 8,
182 "output_type": "execute_result"
186 "mailbox.select('INBOX', readonly=True)"
191 "execution_count": 9,
200 " [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'])"
203 "execution_count": 9,
205 "output_type": "execute_result"
209 "mailbox.search(None, \"ALL\")"
214 "execution_count": 10,
222 "('OK', [b'164 165 166 167 168 169 170 171 172'])"
225 "execution_count": 10,
227 "output_type": "execute_result"
231 "resp, nums = mailbox.search(None, \"SINCE 23-Mar-2016\")\n",
237 "execution_count": 11,
245 "[b'164', b'165', b'166', b'167', b'168', b'169', b'170', b'171', b'172']"
248 "execution_count": 11,
250 "output_type": "execute_result"
259 "execution_count": 12,
268 " [(b'172 (RFC822 {4406}',\n",
269 " 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",
273 "execution_count": 12,
275 "output_type": "execute_result"
279 "all_resp = mailbox.fetch(nums[0].split()[-1], '(RFC822)')\n",
285 "execution_count": 13,
292 "output_type": "stream",
294 "Return-Path: <noreply-dmarc-support@google.com>\r\n",
295 "Delivered-To: dmarc@njae.me.uk\r\n",
296 "Received: from localhost (localhost [127.0.0.1])\r\n",
297 "\tby mail.njae.me.uk (Postfix) with ESMTP id B966C8F\r\n",
298 "\tfor <dmarc@njae.me.uk>; Mon, 28 Mar 2016 11:11:48 +0100 (BST)\r\n",
299 "X-Virus-Scanned: Debian amavisd-new at njae.me.uk\r\n",
300 "Authentication-Results: ogedei.njae.me.uk (amavisd-new);\r\n",
301 "\tdkim=pass (2048-bit key) header.d=google.com\r\n",
302 "Received: from mail.njae.me.uk ([127.0.0.1])\r\n",
303 "\tby localhost (ogedei.njae.me.uk [127.0.0.1]) (amavisd-new, port 10024)\r\n",
304 "\twith ESMTP id GOe6I1LLVNl9 for <dmarc@njae.me.uk>;\r\n",
305 "\tMon, 28 Mar 2016 11:11:47 +0100 (BST)\r\n",
306 "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",
307 "Authentication-Results: mail.njae.me.uk; dmarc=pass header.from=google.com\r\n",
308 "Authentication-Results: mail.njae.me.uk; dkim=pass\r\n",
309 "\treason=\"2048-bit key; unprotected key\"\r\n",
310 "\theader.d=google.com header.i=@google.com header.b=FskZAi7J;\r\n",
311 "\tdkim-adsp=pass; dkim-atps=neutral\r\n",
312 "Received: from mail-io0-f202.google.com (mail-io0-f202.google.com [209.85.223.202])\r\n",
313 "\tby mail.njae.me.uk (Postfix) with ESMTPS id CDAA850\r\n",
314 "\tfor <dmarc@njae.me.uk>; Mon, 28 Mar 2016 11:11:46 +0100 (BST)\r\n",
315 "Received: by mail-io0-f202.google.com with SMTP id e3so1655636ioa.1\r\n",
316 " for <dmarc@njae.me.uk>; Mon, 28 Mar 2016 03:11:46 -0700 (PDT)\r\n",
317 "DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n",
318 " d=google.com; s=20120113;\r\n",
319 " h=mime-version:message-id:date:subject:from:to:content-disposition\r\n",
320 " :content-transfer-encoding;\r\n",
321 " bh=ZMmMsYb7psOB4wlBTQUv+llYFZLud7uqkJWOqTZoywc=;\r\n",
322 " b=FskZAi7J5MJ/Py4sgZaL4dHbNcmccPHDWlFnblx0RT0Dlfb35hDkjtYg5ageqyFowe\r\n",
323 " o4hDspB8+L7cBsY+ftdbMhneveFpKvDgwZqq/88iMOWLuUN39ZWMC7m/XIz2CZhUlLMz\r\n",
324 " xE25EhSOW9xiWWBOESZzIfCvSOoTuyfxMTUFq1uvARg2NUOAdrFTLTivAsMyK2RNkisM\r\n",
325 " SrQRcwDaMLIlQw6FzG+gsO3u8wrT6ckd0fHJtkGptab6CqhEwdkY3kJMCmiasoP/io2v\r\n",
326 " KEsQCkByjHJgnL4tFu5yznLggBrbbvdK4HonSGKDi7cHyuoImxaVZNVMQhaYRnyPqj7j\r\n",
328 "X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n",
329 " d=1e100.net; s=20130820;\r\n",
330 " h=x-gm-message-state:mime-version:message-id:date:subject:from:to\r\n",
331 " :content-disposition:content-transfer-encoding;\r\n",
332 " bh=ZMmMsYb7psOB4wlBTQUv+llYFZLud7uqkJWOqTZoywc=;\r\n",
333 " b=OJjK6bq/e//bsrZJ503gIDT0b582UN5hgfMRT+iJVwtH7ombD4ld+S/+NOfWVTwq8J\r\n",
334 " FoHVodNZjznUtkoOVOm3BFbliMPyxHoYKdbWyYgYH5KzlD9Iv81N5djl50nxdWNkbhK1\r\n",
335 " CZHike9tfLHF82v6i8BIRMubK8UHyCCOpVgFMM+GK3tTdyA7BY/0jXNqzfTDbS/FyeoW\r\n",
336 " sH/sckfOf4HN9DRgNbZ78aq5c1bAcx/N7Fn7+53uLBxw82XUd7JFi10kMd3jvPbHMORa\r\n",
337 " YQgyPoQxuQPvjfU0KTJiXQt+iP+ksHl0DO9umo+c5WzLdHk8QV1ryS5OEhUrfaORqK8a\r\n",
339 "X-Gm-Message-State: AD7BkJLC5599FbOXiJoIKq3UlGXdkIr5BkghJuDHCJeDAQVhAr64/XYgB+fejr5uDj8FvDHPPSPVXA==\r\n",
340 "MIME-Version: 1.0\r\n",
341 "X-Received: by 10.182.243.135 with SMTP id wy7mr16780454obc.8.1459159905131;\r\n",
342 " Mon, 28 Mar 2016 03:11:45 -0700 (PDT)\r\n",
343 "Message-ID: <16143280651570354241@google.com>\r\n",
344 "Date: Mon, 28 Mar 2016 10:11:45 +0000\r\n",
345 "Subject: Report domain: njae.me.uk Submitter: google.com Report-ID: 16143280651570354241\r\n",
346 "From: noreply-dmarc-support@google.com\r\n",
347 "To: dmarc@njae.me.uk\r\n",
348 "Content-Type: application/zip; \r\n",
349 "\tname=\"google.com!njae.me.uk!1459036800!1459123199.zip\"\r\n",
350 "Content-Disposition: attachment; \r\n",
351 "\tfilename=\"google.com!njae.me.uk!1459036800!1459123199.zip\"\r\n",
352 "Content-Transfer-Encoding: base64\r\n",
354 "UEsDBAoAAAAIAD1PfEjhndhx2QEAAHoEAAAvAAAAZ29vZ2xlLmNvbSFuamFlLm1lLnVrITE0NTkw\r\n",
355 "MzY4MDAhMTQ1OTEyMzE5OS54bWytVMtyozAQvOcrKN+NEAbW3lKUPeULds+ULAasNUgqSeTx9yss\r\n",
356 "8YiTqlz2hOiZ6ZnuEZCnt6FPXsBYoeTjDqfZLgHJVSNk97j78/t5f9wlT/SBtADNmfErfUgSYkAr\r\n",
357 "4+oBHGuYYxPmUWW6WrIBaKdU10PK1UDQAoYcGJjoqVSeoX/fNwMzfG9HPdH92paFvFjz5gyruZKO\r\n",
358 "cVcL2Sp6cU7bnwjF0nQtRQwxaV/BoLyoqvKYea7P9YE4yhANxRUuDvkxq0pc/sgOZZEXmKA1HvK9\r\n",
359 "VqgNk11U46EzdEJSXJSn7FAdM98tIHMcZHOL4vyATyc/i5zJ0Ee2pdvWVKJVL/h7rcdzL+wFlkGU\r\n",
360 "t0dS+ZdBOkA6Xj1bgEKcNVcxUENQOETQ6vaGTc8Aab8JCQTp+G5nwM6I5o7iSdZ0uI351UjeSa7M\r\n",
361 "PJ1Rr4t+q0bDoRaa5jhPq1NalmmV+wYLPmdyNUpHfSgcZji2gxfWj96wZg5MLgirlRXO39w49hbZ\r\n",
362 "5E0eaGatT1jsiHrbGFg82Ui86+k3NAsjogHpRCv8d7OUXYA1YOrWqOHDZrZ4JPpUTtjoLrUBO/Zu\r\n",
363 "Zbyb9putxys9UURR8WXRteUjG8X/g3u9VOhey5QcrgdB62/kH1BLAQIKAAoAAAAIAD1PfEjhndhx\r\n",
364 "2QEAAHoEAAAvAAAAAAAAAAAAAAAAAAAAAABnb29nbGUuY29tIW5qYWUubWUudWshMTQ1OTAzNjgw\r\n",
365 "MCExNDU5MTIzMTk5LnhtbFBLBQYAAAAAAQABAF0AAAAmAgAAAAA=\r\n",
371 "print(all_resp[1][0][1].decode('utf-8'))"
376 "execution_count": 14,
385 " [(b'172 (BODY[1] {912}',\n",
386 " 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",
390 "execution_count": 14,
392 "output_type": "execute_result"
396 "all_resp = mailbox.fetch(nums[0].split()[-1], '(BODY[1])')\n",
402 "execution_count": 15,
411 " [b'172 (BODY (\"application\" \"zip\" (\"name\" \"google.com!njae.me.uk!1459036800!1459123199.zip\") NIL NIL \"base64\" 912))'])"
414 "execution_count": 15,
416 "output_type": "execute_result"
420 "all_resp = mailbox.fetch(nums[0].split()[-1], '(BODY)')\n",
426 "execution_count": 16,
437 "execution_count": 16,
439 "output_type": "execute_result"
448 "execution_count": 17,
459 "execution_count": 17,
461 "output_type": "execute_result"
465 "type(all_resp[1][0][1])"
470 "execution_count": 18,
478 "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'"
481 "execution_count": 18,
483 "output_type": "execute_result"
487 "msg = mailbox.fetch(nums[0].split()[-1], '(RFC822)')[1][0][1]\n",
493 "execution_count": 19,
501 "<email.message.Message at 0x7f1bbc67e048>"
504 "execution_count": 19,
506 "output_type": "execute_result"
510 "pmsg = email.parser.BytesParser()\n",
511 "pmsg.parsebytes(msg)"
516 "execution_count": 20,
524 "<email.message.Message at 0x7f1bbc67e390>"
527 "execution_count": 20,
529 "output_type": "execute_result"
533 "pmsg = email.message_from_bytes(msg)\n",
539 "execution_count": 21,
550 "execution_count": 21,
552 "output_type": "execute_result"
556 "pmsg.get_content_type()"
561 "execution_count": 22,
569 "'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'"
572 "execution_count": 22,
574 "output_type": "execute_result"
583 "execution_count": 23,
591 "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\""
594 "execution_count": 23,
596 "output_type": "execute_result"
600 "pmsg.get_payload(decode=True)"
605 "execution_count": 24,
611 "# io.BytesIO(pmsg.get_payload(decode=True))\n",
612 "zfp = zipfile.ZipFile(io.BytesIO(pmsg.get_payload(decode=True)))"
617 "execution_count": 25,
625 "'google.com!njae.me.uk!1459036800!1459123199.xml'"
628 "execution_count": 25,
630 "output_type": "execute_result"
634 "zfp.infolist()[0].filename"
639 "execution_count": 26,
645 "def walk(node, indent=0):\n",
646 " for child in node:\n",
647 " print(' '*indent, child.tag, ':', child.text.strip())\n",
648 " walk(child, indent+2)"
653 "execution_count": 27,
664 "execution_count": 28,
671 "output_type": "stream",
673 " report_metadata : \n",
674 " org_name : google.com\n",
675 " email : noreply-dmarc-support@google.com\n",
676 " extra_contact_info : https://support.google.com/a/answer/2466580\n",
677 " report_id : 16143280651570354241\n",
679 " begin : 1459036800\n",
680 " end : 1459123199\n",
681 " policy_published : \n",
682 " domain : njae.me.uk\n",
690 " source_ip : 212.69.55.62\n",
692 " policy_evaluated : \n",
693 " disposition : none\n",
697 " header_from : njae.me.uk\n",
698 " auth_results : \n",
700 " domain : njae.me.uk\n",
703 " domain : njae.me.uk\n",
709 "with zipfile.ZipFile(io.BytesIO(pmsg.get_payload(decode=True))) as zf:\n",
710 " fn = zf.infolist()[0].filename\n",
711 " contents = zf.read(fn).decode('utf-8')\n",
712 " root = xml.etree.ElementTree.fromstring(contents)\n",
718 "execution_count": 82,
724 "ename": "RuntimeError",
725 "evalue": "No active exception to reraise",
726 "output_type": "error",
728 "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
729 "\u001b[1;31mRuntimeError\u001b[0m Traceback (most recent call last)",
730 "\u001b[1;32m<ipython-input-82-26814ed17a01>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mraise\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
731 "\u001b[1;31mRuntimeError\u001b[0m: No active exception to reraise"
741 "execution_count": 29,
749 "('OK', [b'Close completed.'])"
752 "execution_count": 29,
754 "output_type": "execute_result"
763 "execution_count": 30,
771 "('BYE', [b'Logging out'])"
774 "execution_count": 30,
776 "output_type": "execute_result"
785 "execution_count": null,
795 "display_name": "Python 3",
796 "language": "python",
804 "file_extension": ".py",
805 "mimetype": "text/x-python",
807 "nbconvert_exporter": "python",
808 "pygments_lexer": "ipython3",