{"id":20292464,"url":"https://github.com/mauricelambert/pyemailtools","last_synced_at":"2026-06-29T15:31:16.506Z","repository":{"id":62580160,"uuid":"320916303","full_name":"mauricelambert/PyEmailTools","owner":"mauricelambert","description":"Analysis and email forgering with SMTP, IMAP and POP3 client (client for emails protocols).","archived":false,"fork":false,"pushed_at":"2021-04-12T19:35:26.000Z","size":121,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T08:35:34.618Z","etag":null,"topics":["email","forensic-analysis","forensics","pypi","pypi-package","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mauricelambert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-12T20:19:28.000Z","updated_at":"2021-11-02T12:24:39.000Z","dependencies_parsed_at":"2022-11-03T21:01:03.635Z","dependency_job_id":null,"html_url":"https://github.com/mauricelambert/PyEmailTools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricelambert%2FPyEmailTools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricelambert%2FPyEmailTools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricelambert%2FPyEmailTools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricelambert%2FPyEmailTools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mauricelambert","download_url":"https://codeload.github.com/mauricelambert/PyEmailTools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241787485,"owners_count":20020101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","forensic-analysis","forensics","pypi","pypi-package","python3"],"created_at":"2024-11-14T15:17:23.467Z","updated_at":"2026-06-29T15:31:16.465Z","avatar_url":"https://github.com/mauricelambert.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyEmailTools\r\n\r\n## Description\r\nPyEmailTools can perform email analysis and email forgering. I am implementing an SMTP, IMAP and POP3 client to make this package easier to use.\r\n\r\n## Requirements\r\nThis package require : \r\n - python3\r\n - python3 Standard Library\r\n\r\n## Installation\r\n```bash\r\npip install PyEmailTools \r\n```\r\n\r\n## Examples\r\n\r\n### Simple usage\r\n\r\n#### Command lines\r\n\r\n##### Forger\r\n```bash\r\nEmailForgering -t \"My Subject\" -T \"receiver.address@domain.com\" -M \"my.server.com\" -O 587 -L -R \"receiver.address@domain.com\" -m \"My message\" -U \"my.address@domain.com\" -P \"my_password\" \"my.address@domain.com\"\r\n```\r\n\r\n##### Analysis\r\n```bash\r\nEmailAnalysis -G -S \"test\" -f \"*.eml\" -i -a -B -s \"@*.com\" \"files\" \r\n# print all IP and email address, for all files with the eml extension in the current directory, search string with \"@\u003csome characters\u003e.com\" in email and save it in file named \"test\u003cid\u003e.eml\"\r\n```\r\n\r\n#### Python3\r\n\r\n##### Forger\r\n```python\r\nfrom PyEmailTools.Forger import Forger\r\nfrom PyEmailTools.SmtpClient import SmtpClient\r\nfrom getpass import getpass\r\n\r\npassword = getpass()\r\nreceiver = \"receiver.address@domain.com\"\r\nsender = \"my.address@domain.com\"\r\n\r\nemail = Forger(sender, titre = \"My Subject\")\r\nemail.add_recipient(receiver)\r\nemail.add_part(\"My message.\", \"plain\")\r\nemail.make_email() # Build the mail\r\n\r\nsmtpclient = SmtpClient(smtp = \"my.server.com\", port = 587, username = sender, password = password)\r\nsmtpclient.send(email, sender, [receiver])\r\n```\r\n\r\n##### Analysis\r\n```python\r\nfrom PyEmailTools.Reader import Reader\r\n\r\nemail = Reader(\"mail.eml\")\r\nemail.make_email() # Read a email file\r\n\r\ndel email.email['To']\r\ndel email.email['Sender']\r\ndel email.email['From'] # Delete some headers values\r\n\r\nemail.email['To'] = \"receiver.address@domain.com\"\r\nemail.email['Sender'] = \"my.address@domain.com\" # Add/Change some headers values\r\n\r\nemail.make_email(email.email.as_bytes()) # Rebuild the email object from bytes\r\nemail.save_in_file(\"mail.eml\") # Save change\r\nemail.print(part = True, attachements = True, email = email.email) # Analysis (with max verbosity level)\r\n\r\n# To send the new email use the SmtpClient class (precedent example)\r\n```\r\n\r\n### Advanced usage\r\n\r\n#### Command lines\r\n\r\n##### Forger\r\n```bash\r\nEmailForgering -t \"My Subject\" -T \"receiver.address@domain.com\" -M \"my.server.com\" -R \"receiver.address@domain.com\" -m \"My message\" \"my.address@domain.com\" \r\n# Some server can send message without authentication.\r\n\r\nEmailForgering -t \"My Subject\" -T \"receiver.address@domain.com\" -M \"my.server.com\" -O 587 -L -D -R \"receiver.address@domain.com\" -S \"mail.eml\" -H \"\u003chtml\u003e\u003cbody\u003e\u003ch1\u003eMessage\u003c/h1\u003e\u003cp\u003eMy HTML message\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e\" -p \"Test\" -N \"my.address@domain.com\" \"my.address@domain.com\" \r\n# Send HTML mail with special name, save it in a file and use a secure connection with debug mode.\r\n\r\nEmailForgering -t \"My Subject\" -T \"fake.receiver@domain.com\" -M \"my.server.com\" -O 587 -L -A \"CustomHostname\" -D -R \"receiver1.address@domain.com,receiver2.address@domain.com\" -S \"mail.eml\" -H \"\u003chtml\u003e\u003cbody\u003e\u003ch1\u003eMessage\u003c/h1\u003e\u003cp\u003eMy HTML message\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e\" -p \"Test\" -k \"keywords,test,email\" -c \"this is my comment\" -F -l \"en,it\" -a \"kali.jpg\" -m \"Simple second message\" -d \"2020-04-02 11:20:03\" -i 3 -s 3 -r 3 -e ROT13 -E \"2020-11-12 09:00:00\" -N \"my.user@domain.com\" -x \"Email HTML with image.\" \"fake.sender@domain.com\" \r\n# Use a fake receiver email (the real receivers can't see other real receivers address), add custom hostname, add keywords header, add comment header, add language, add attachment, add second body, change the sending date, add importance level, add sensibility level, add priority level, add the encrypted header, add expiring date and use your address to send this message but indicate a fake sender address.\r\n```\r\n\r\n##### Analysis\r\n```bash\r\nEmailAnalysis -K -p 1 -s \"[0-9]{4,10}\" -R -l 5 -H \"From\" -g \"To\" -i -a -N \"my.server.com\" -U \"my.address@domain.com\" -P \"my_password\" -L -D \"imap\" \r\n# Research 5 emails with a number code (regex : \"[0-9]{4,10}\") or with the header \"From\", print all emails with verbosity level 1, reverse the server email order (to get last emails), debug the imap ssl connection.\r\n\r\nEmailAnalysis -k -p 4 -s \"Dear\" -N \"my.server.com\" -r 1 -H \"From\" -v \"receiver.address@domain.com\" -i -a -g \"Subject\" -O 995 -U \"my.address@domain.com\" -L -D \"pop3\" \r\n# Print (with verbosity level 4) emails with value of header \"From\" = \"receiver.address@domain.com\" or with the string \"Dear\", print Subject value, IP address and email address of all emails, perform 1 pop3 request on my.server.com on port 995 with username : my.address@domain.com (the script ask the password), debugging connection and using SSL.\r\n```\r\n\r\n#### Python3\r\n\r\n##### Forger\r\n```python\r\nfrom PyEmailTools.Forger import Forger\r\nfrom PyEmailTools.SmtpClient import SmtpClient\r\n\r\nfake_receivers = \"fake.receiver@domain.com\"\r\nreceivers = [\"receiver1.address@domain.com\", \"receiver1.address@domain.com\"]\r\nfake_sender = \"fake.sender@domain.com\"\r\nsender = \"my.address@domain.com\"\r\n\r\nemail = Forger(fake_sender, titre = \"My Subject\", pseudo = \"Custom Name\", comments = \"My comments\", \r\n       keywords = [\"test\", \"forger\", \"email\", \"spoof\"], date = datetime(2019, 5, 3), encrypted = \"ROT13\", \r\n       expires = datetime(2021, 1, 1), importance = 3, sensitivity = 3, language = [\"test\", \"forger\", \"email\", \"spoof\"], \r\n       priority = 3, default_text = \"Email HTML with image.\")\r\nemail.add_recipient(fake_receivers)\r\nemail.add_image(\"image.jpg\", \"\u003chtml\u003e\u003cbody\u003e\u003cp\u003eMessage with an image.\u003c/p\u003e[image]\u003c/body\u003e\u003c/html\u003e\")\r\nemail.add_part(\"\u003chtml\u003e\u003cbody\u003e\u003cp\u003eMessage without image.\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e\", \"html\")\r\nemail.add_attachement(\"attachment.txt\")\r\nemail.add_part(\"My message.\", \"plain\")\r\nemail.email[\"Fake\"] = \"Add a fake header\"\r\nemail.make_email()\r\nemail.save_in_file(\"mail.eml\")\r\nemail.print(part = True, attachements = True, email = email.email)\r\n\r\nsmtpclient = SmtpClient(smtp = \"my.server.com\", port = 587, debug = True)\r\nsmtpclient.send(email, sender, receivers, \"CustomHostname\")\r\n```\r\n\r\n##### Analysis\r\n```python\r\nfrom PyEmailTools.Reader import Reader\r\nfrom PyEmailTools.ImapClient import ImapClient\r\n\r\nclient = ImapClient(server=\"my.server.com\", port=None, username=\"my.address@domain.com\", password=\"my_password\", ssl=True, debug=0)\r\nfor total, index, data in client.get_all_mail():\r\n\temail = Reader()\r\n\temail.make_email(data)\r\n\t\r\n\tprint(f\"\"\"\r\nEmail {index} / {total}\r\n\\tFrom: {email.headers.get(\"From\")}\r\n\\tTo: {email.headers.get(\"To\")}\r\n\\tSubject: {email.headers.get(\"Subject\")}\r\n\\tBody:\r\n\"\"\")\r\n\t\r\n\tfor name, text in email.part.items():\r\n\t\tif \"txt\" in name:\r\n\t\t\ttext = text.replace(\"\\n\", \"\\n\\t\\t\")\r\n\t\t\tprint(f\"\\t\\t{name} : {text}\")\r\n\r\n\tif index \u003e 3 :\r\n\t\tbreak\r\n```\r\n\r\n### Python executable\r\n\r\n```bash\r\npython3 PyEmailTools.pyz forger -t \"My Subject\" -T \"receiver.address@domain.com\" -M \"my.server.com\" -O 587 -L -R \"receiver.address@domain.com\" -m \"My message\" -U \"my.address@domain.com\" -P \"my_password\" \"my.address@domain.com\"\r\n\r\n# OR\r\nchmod u+x PyEmailTools.pyz # add execute rights\r\n./PyEmailTools.pyz analysis -G -S \"test\" -f \"*.eml\" -i -a -B -s \"@*.com\" \"files\"  # execute file\r\n```\r\n\r\n### Python module (command line):\r\n\r\n```bash\r\npython3 -m PyEmailTools analysis -G -S \"test\" -f \"*.eml\" -i -a -B -s \"@*.com\" \"files\"\r\npython3 -m PyEmailTools.Forger -t \"My Subject\" -T \"receiver.address@domain.com\" -M \"my.server.com\" -O 587 -L -R \"receiver.address@domain.com\" -m \"My message\" -U \"my.address@domain.com\" -P \"my_password\" \"my.address@domain.com\"\r\n```\r\n\r\n## Links\r\n - [Github Page](https://github.com/mauricelambert/PyEmailTools)\r\n - [Documentation Forger](https://mauricelambert.github.io/info/python/security/PyEmailTools/Forger.html)\r\n - [Documentation Email](https://mauricelambert.github.io/info/python/security/PyEmailTools/Email.html)\r\n - [Documentation Reader](https://mauricelambert.github.io/info/python/security/PyEmailTools/Reader.html)\r\n - [Documentation ImapClient](https://mauricelambert.github.io/info/python/security/PyEmailTools/ImapClient.html)\r\n - [Documentation PopClient](https://mauricelambert.github.io/info/python/security/PyEmailTools/PopClient.html)\r\n - [Documentation SmtpClient](https://mauricelambert.github.io/info/python/security/PyEmailTools/SmtpClient.html)\r\n - [Download as python executable](https://mauricelambert.github.io/info/python/security/PyEmailTools.pyz)\r\n - [Pypi package](https://pypi.org/project/PyEmailTools/)\r\n\r\n## Licence\r\nLicensed under the [GPL, version 3](https://www.gnu.org/licenses/).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauricelambert%2Fpyemailtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmauricelambert%2Fpyemailtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauricelambert%2Fpyemailtools/lists"}