{ "info": { "author": "Akshay Kumar", "author_email": "akshay.kmr4321@gmail.com", "bugtrack_url": null, "classifiers": [], "description": ".. raw:: html\n\n

\n\nEmailTrail\n\n.. raw:: html\n\n

\n\n.. raw:: html\n\n

\n\n.. raw:: html\n\n \n\n.. raw:: html\n\n

\n\n|Travis branch| |PRs Welcome|\n\n.. raw:: html\n\n

\n\nAnalyse hops taken by an Email to reach you. Get structured information\nabout each hop - Hostnames, Protocol used, Timestamp, and Delay.\n\n.. raw:: html\n\n

\n\n**In your project:** ``pip install emailtrail`` or if you use\n`pipenv `__ like me ``pipenv install emailtrail``\n\n.. raw:: html\n\n \n\n.. raw:: html\n\n \n\nTable of Contents\n-----------------\n\n- `Usage <#usage>`__\n- `Caveats <#caveats>`__\n- `Contributing <#contributing>`__\n- `Miscellaneous <#miscellaneous>`__\n\n.. raw:: html\n\n \n\nUsage\n-----\n\nWe can analyse an email source or raw headers\n\n.. code:: python\n\n email = \"\"\"\n Delivered-To: money@capitalism.com\n Received: by 10.129.52.209 with SMTP id b200csp1430876ywa;\n Tue, 10 Oct 2017 01:17:02 -0700 (PDT)\n X-Received: by 10.31.153.20 with SMTP id b20mr6116862vke.110.1507623422746;\n Tue, 10 Oct 2017 01:17:02 -0700 (PDT)\n Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65])\n by mx.google.com with SMTPS id b31sor1345013uaa.124.2017.10.10.01.17.02\n for \n (Google Transport Security);\n Tue, 10 Oct 2017 01:17:02 -0700 (PDT)\n Received-SPF: pass (google.com: domain of bags@test_email.ua.edu designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65;\n X-Received: by 10.176.85.196 with SMTP id w4mr6874179uaa.75.1507623422198; Tue, 10 Oct 2017 01:17:02 -0700 (PDT)\n MIME-Version: 1.0\n Received: by 10.103.79.86 with HTTP; Tue, 10 Oct 2017 01:17:01 -0700 (PDT)\n From: Mr. Money Bags \n Date: Tue, 10 Oct 2017 01:17:01 -0700\n Subject:\n To: money@capitalism.com;\n Content-Type: text/plain; charset=\"UTF-8\"\n Bcc: satan@wallstreet.com\n\n A business opportunity awaits\n \"\"\"\n\nLets analyse it\n^^^^^^^^^^^^^^^\n\n.. code:: python\n\n import emailtrail\n emailtrail.analyse(email)\n\n.. code:: python\n\n {\n 'To': u'money@capitalism.com;',\n 'From': u'Mr. Money Bags ',\n 'Bcc': u'satan@wallstreet.com',\n 'Cc': u'None',\n 'total_delay': 1,\n 'trail': [\n {\n 'delay': 0,\n 'from': '',\n 'protocol': 'HTTP',\n 'receivedBy': '10.103.79.86',\n 'timestamp': 1507623421\n },\n {\n 'delay': 1,\n 'from': 'mail-sor-f65.google.com',\n 'protocol': 'SMTPS',\n 'receivedBy': 'mx.google.com',\n 'timestamp': 1507623422\n },\n {\n 'delay': 0,\n 'from': '',\n 'protocol': 'SMTP',\n 'receivedBy': '10.129.52.209',\n 'timestamp': 1507623422\n }\n ]\n }\n\nThe analyse function returns a python dictionary. The trail shows the\nemail hops sorted in chronological order. Each intermediary email server\nadds a ``Received`` header to the mail, from which the module parses the\nfollowing information:\n\n- ``protocol`` : e.g HTTP, SMTP etc.\n- ``from`` : The name the sending computer gave for itself\n- ``receivedBy``: The receiving computers name\n- ``timestamp`` : Unix epoch\n\nAn empty string value is set for fields which couldn\u2019t be determined. -\n``delay``: The delay (in seconds) is computed by taking the difference\nof two consecutive hops. In above example there was a delay of ``1 sec``\nfrom ``10.103.79.86`` to ``mx.google.com``\n\nAnalysing a single ``Received`` header\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code:: python\n\n >>> header = \"\"\"from mail-vk0-x233.google.com (mail-vk0-x233.google.com. [2607:f8b0:400c:c05::233])\\n by mx.google.com with ESMTPS id d124si110912930vka.142.2016.01.12.10.20.45\\n for \\n (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\\n Wed, 16 Dec 2015 16:34:34 -0600 \"\"\"\n\n >>> from emailtrail import analyse_hop, extract_protocol, extract_from_label, extract_received_by_label, extract_timestamp\n\n >>> extract_protocol(header)\n \"ESMTPS\"\n\n >>> extract_from_label(header)\n \"mail-vk0-x233.google.com\"\n\n >>> extract_received_by_label(header)\n \"mx.google.com\"\n\n >>> extract_timestamp(header)\n 1450305274\n\n >>> analyse_hop(header)\n {\n \"from\": \"mail-vk0-x233.google.com\",\n \"receivedBy\": \"mx.google.com\",\n \"protocol\": \"ESMTPS\",\n \"timestamp\": 1450305274\n }\n\nCaveats\n~~~~~~~\n\n- Sometimes during delay calculation the timestamp difference may be\n negative. It\u2019s not possible for a server to recieve the email before\n previous one, It means that either one or both of the servers clocks\n are off. We assume a delay of ``0`` for this hop.\n\nContributing\n------------\n\nemailtrail uses `pipenv `__ for managing virtual env\nand package versions. - Fork the repo and clone it. - In project root:\n``pipenv install --dev``. This installs packages required for testing\nand linting - Jump into your virutal env: ``pipenv shell`` - Running\ntests: ``pytest`` - If you want to understand the code, read the test\ncases first. - Make your changes -> Pass the tests -> Push to your\nbranch -> Create pull request -> Profit ??\n\nMiscellaneous\n^^^^^^^^^^^^^\n\nIn the middle of developing this module, I switched to TDD. Albeit slow\nfor a first timer initially, It proved to be a very effective approach\nlater on. - Forces you to think how to structure your code. - Less\ncoupling, small functions with minimal to none side effects, well\ndefined interfaces. - Confidence in refactoring code quickly. (Everyone\nloves it when their investments pay off)\n\n.. |Travis branch| image:: https://img.shields.io/travis/akshayKMR/emailtrail/master.svg?style=flat-square\n :target: https://travis-ci.org/akshayKMR/emailtrail\n.. |PRs Welcome| image:: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\n :target: http://makeapullrequest.com\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/akshayKMR/emailtrail", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "emailtrail", "package_url": "https://pypi.org/project/emailtrail/", "platform": "", "project_url": "https://pypi.org/project/emailtrail/", "project_urls": { "Homepage": "https://github.com/akshayKMR/emailtrail" }, "release_url": "https://pypi.org/project/emailtrail/0.3.21/", "requires_dist": null, "requires_python": "", "summary": "Analyse hops taken by an Email to reach you. Get structured information about each hop - Hostnames, Protocol used, Timestamp, and Delay", "version": "0.3.21" }, "last_serial": 3422675, "releases": { "0.3.14": [ { "comment_text": "", "digests": { "md5": "995b8930f491ec3674435c894b6f3347", "sha256": "ac0402788d39dee70ad9de869cdced6a7dade261440c7ac1c05a4f47a3547be5" }, "downloads": -1, "filename": "emailtrail-0.3.14.tar.gz", "has_sig": false, "md5_digest": "995b8930f491ec3674435c894b6f3347", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3972, "upload_time": "2017-10-18T20:26:30", "url": "https://files.pythonhosted.org/packages/15/cb/7a20dabab9fb6c97389d1d73582c3f01241ffe02a44f2db4d451e466865b/emailtrail-0.3.14.tar.gz" } ], "0.3.15": [ { "comment_text": "", "digests": { "md5": "7cde2fde4e00d6c7b3247aa2b0bfaa7b", "sha256": "4cd5c4b1122bd2272e7d9101f49b73d7e8052828edde26b141d11f9d35295cdc" }, "downloads": -1, "filename": "emailtrail-0.3.15.tar.gz", "has_sig": false, "md5_digest": "7cde2fde4e00d6c7b3247aa2b0bfaa7b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7035, "upload_time": "2017-10-19T09:11:51", "url": "https://files.pythonhosted.org/packages/27/f8/79443009df457c5fc7cbace4ea5033ebdf624c3b595e2068e1db43eb7af2/emailtrail-0.3.15.tar.gz" } ], "0.3.16": [ { "comment_text": "", "digests": { "md5": "56e77b2e8322e3c2676dd62e6205d1ee", "sha256": "e648540bc20e50e515a8be9402535c0227d0560cb0ffc417c410d56a645676cc" }, "downloads": -1, "filename": "emailtrail-0.3.16.tar.gz", "has_sig": false, "md5_digest": "56e77b2e8322e3c2676dd62e6205d1ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7019, "upload_time": "2017-10-20T12:23:52", "url": "https://files.pythonhosted.org/packages/ff/89/ce52574758044e0c09f36af82e0dc8d1cbfde74bcb87e43e862bccda6257/emailtrail-0.3.16.tar.gz" } ], "0.3.17": [ { "comment_text": "", "digests": { "md5": "93b7fc1537f178dba42d0c933253e30e", "sha256": "c104208b22a69e36ccd84619d6f29d1806735c840b239fa1032c97a7dfe7c018" }, "downloads": -1, "filename": "emailtrail-0.3.17.tar.gz", "has_sig": false, "md5_digest": "93b7fc1537f178dba42d0c933253e30e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7136, "upload_time": "2017-10-21T17:18:47", "url": "https://files.pythonhosted.org/packages/c1/38/b08c4ee0dbc87c03f68ca41fe311bdea85e68bd7b4f28734f72e98a79e31/emailtrail-0.3.17.tar.gz" } ], "0.3.18": [ { "comment_text": "", "digests": { "md5": "9a115fc0fcb790593850fac6aeb31e82", "sha256": "f3371cbda7da833951e4a6f331680b3416383514835e2261dc52b663769c16b3" }, "downloads": -1, "filename": "emailtrail-0.3.18.tar.gz", "has_sig": false, "md5_digest": "9a115fc0fcb790593850fac6aeb31e82", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7135, "upload_time": "2017-10-29T16:16:48", "url": "https://files.pythonhosted.org/packages/4a/d3/2b46d30aebace57aa150bfa9d978610e044e876a85235c64f7d1b28bb216/emailtrail-0.3.18.tar.gz" } ], "0.3.20": [ { "comment_text": "", "digests": { "md5": "329fca291355b065b40c6f6bbcaaecd2", "sha256": "3059c6a33e347479268d180796bd2eb81c52c63fc943f77125db2807872453ce" }, "downloads": -1, "filename": "emailtrail-0.3.20.tar.gz", "has_sig": false, "md5_digest": "329fca291355b065b40c6f6bbcaaecd2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7126, "upload_time": "2017-10-29T17:12:28", "url": "https://files.pythonhosted.org/packages/2e/0d/2bb4ba57e61f67e16f7aaadc453f571452b31a4de712ed4b258150bab9d5/emailtrail-0.3.20.tar.gz" } ], "0.3.21": [ { "comment_text": "", "digests": { "md5": "0b166cba277f36aaf870340699d751ba", "sha256": "2286ab24ab4b27517c871538f8fbfc908d2ac786ba8a306cf5f892078dad87dd" }, "downloads": -1, "filename": "emailtrail-0.3.21.tar.gz", "has_sig": false, "md5_digest": "0b166cba277f36aaf870340699d751ba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7222, "upload_time": "2017-12-17T06:41:12", "url": "https://files.pythonhosted.org/packages/9d/13/36fd79bfb0e6ba531b5601ea083c13fa74b7f0a827ceba3eea07c0d5275a/emailtrail-0.3.21.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0b166cba277f36aaf870340699d751ba", "sha256": "2286ab24ab4b27517c871538f8fbfc908d2ac786ba8a306cf5f892078dad87dd" }, "downloads": -1, "filename": "emailtrail-0.3.21.tar.gz", "has_sig": false, "md5_digest": "0b166cba277f36aaf870340699d751ba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7222, "upload_time": "2017-12-17T06:41:12", "url": "https://files.pythonhosted.org/packages/9d/13/36fd79bfb0e6ba531b5601ea083c13fa74b7f0a827ceba3eea07c0d5275a/emailtrail-0.3.21.tar.gz" } ] }