{ "info": { "author": "Christopher H. Todd", "author_email": "Christopher.Hayden.Todd@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8" ], "description": "# Christopher H. Todd's Python Lib for Emails\n\nThe ctodd-python-lib-email project is responsible for interacting with emails. Specifically, it is used for reading and sending emails from a user's account.\n\nThe library relies on Python's gmail-api package, and is wrapped with custom/specific exception handling, simpler interactions, and a more functional style to reduce code in projects dealing with Gmail API directly.\n\nThis library also has assumptions about token files and credential files, which may take pre-work depending on the usecase.\n\n## Table of Contents\n\n* [Dependencies](#dependencies)\n* [Libraries](#libraries)\n* [Example Scripts](#example-scripts)\n* [Notes](#notes)\n* [TODO](#todo)\n\n## Dependencies\n\n### Python Packages\n\n* google-api-python-client==1.7.9\n* google-auth-httplib2==0.0.3\n* google-auth-oauthlib==0.4.0\n* google-auth==1.6.3\n* oauthlib==3.0.2\n\n## Libraries\n\n### [gmail_helpers.py](https://github.com/ChristopherHaydenTodd/ctodd-python-lib-email/blob/master/email_helpers/gmail_helpers.py)\n\nGmail Helpers.\n\nThis library is used to interact with Google's gmail application. Will\ninclude sending emails, pulling emails, etc.\n\nFunctions:\n\n```\ndef get_gmail_service(gmail_credentials):\n \"\"\"\n Purpose:\n Connect to Gmail with credentials file that is locally stored (or\n log in) so that you can read/utilize gmail services.\n Args:\n gmail_credentials (Gmail Credentials Obj): Authenticated Gmail credentials object\n that can be used to connect to Gmail\n Return:\n gmail_service (Gmail Services Obj): A connecteed Gmail service object\n \"\"\"\n```\n\n```\ndef get_gmail_credentials(\n gmail_credentials_file=\"~/.gmail/gmail_credentials.json\",\n gmail_token_file=\"~/.gmail/gmail_token.pickle\",\n):\n \"\"\"\n Purpose:\n Create or reauthenticate a token for Gmail services using a credentials file\n located on the host or reauthenticate an already existing token\n Args:\n gmail_credentials_file (String): Filename of the Gmail credentials file\n gmail_token_file (String): Filename of the Gmail token file\n Return:\n gmail_credentials (Gmail Credentials Obj): Authenticated Gmail credentials object\n that can be used to connect to Gmail\n \"\"\"\n```\n\n```\ndef generate_gmail_token(gmail_credentials_file):\n \"\"\"\n Purpose:\n Create a new gmail token for authentication of services\n Args:\n gmail_credentials_file (String): Filename of the Gmail credentials file\n Return:\n gmail_credentials (Gmail Credentials Obj): Authenticated Gmail credentials object\n that can be used to connect to Gmail\n \"\"\"\n```\n\n```\ndef send_email(gmail_service, email_msg):\n \"\"\"\n Purpose:\n Send email through a gmail server object\n Args:\n gmail_service (Gmail Service Object): Connected Gmail Service\n email_msg (Message Object): Email message to send through Gmail\n Return:\n N/A\n \"\"\"\n```\n\n```\ndef build_msg_obj(\n email_from,\n email_subject,\n email_body,\n email_to,\n email_cc=[],\n email_bcc=[],\n email_attachments=[],\n):\n \"\"\"\n Purpose:\n Build and encode an email message object to send through a gmail\n server\n Args:\n email_from (String): From address for the email\n email_subject (String): Subject of the email\n email_body (String): String body of the email\n email_to (List of Strings): List of email addresses to add as a TO on email\n email_cc (List of Strings): List of email addresses to add as a CC on email.\n Defaults to [] (no addresses)\n email_bcc (List of Strings): List of email addresses to add as a BCC on email.\n Defaults to [] (no addresses)\n email_attachments (List of Strings): List of filenames that will be attached\n to the email. Defaults to [] (no attachmensts)\n Return:\n email_msg (Message Object): Encoded email message object ready to be sent\n \"\"\"\n```\n\n```\ndef encode_attachment_for_email(attachment_filename):\n \"\"\"\n Purpose:\n Guess the encoding and prepare the attachment for being added to the email\n Args:\n attachment_filename (String): String filename of the attachment\n Returns:\n attachment (Encoded Attachment Obj): Encoded Attachment Obj ready to be\n added to the email message\n \"\"\"\n```\n\n## Example Scripts\n\nExample executable Python scripts/modules for testing and interacting with the library. These show example use-cases for the libraries and can be used as templates for developing with the libraries or to use as one-off development efforts.\n\n### [send_test_email_with_gmail.py](https://github.com/ChristopherHaydenTodd/ctodd-python-lib-email/blob/master/example_usage/send_test_email_with_gmail.py)\n\n```\n Purpose:\n Send a test email utilizing Gmail\n\n Steps:\n - Generate a token\n - Connect to Google Service\n - Build Message Object\n - Send Email\n\n function call:\n send_test_email_with_gmail.py [-h]\n [--gmail-token-file GMAIL_TOKEN_FILE]\n [--gmail-credentials-file GMAIL_CREDENTIALS_FILE]\n [--email-cc EMAIL_CC]\n [--email-bcc EMAIL_BCC]\n [--email-attachements EMAIL_ATTACHEMENTS]\n --gmail-account GMAIL_ACCOUNT --email-to\n EMAIL_TO --email-subject EMAIL_SUBJECT\n --email-body EMAIL_BODY\n\n example call:\n python3.6 send_test_email_with_gmail.py \\\n --gmail-account=\"gmail_account@gmail.com\" \\\n --email-to=\"gmail_account_to@gmail.com\" \\\n --email-subject=\"Test Email\" \\\n --email-body=\"This is a test email\" \\\n --email-cc=\"gmail_account_cc1@gmail.com\" \\\n --email-cc=\"gmail_account_cc2@gmail.com\" \\\n --email-bcc=\"gmail_account_bcc@gmail.com\" \\\n --email-attachements=\"/pah/to/file.png\" \\\n --email-attachements=\"/pah/to/file2.png\"\n```\n\n## Notes\n\n - Relies on f-string notation, which is limited to Python3.6. A refactor to remove these could allow for development with Python3.0.x through 3.5.x\n - Only implemented Gmail, other email providers not supported\n\n## TODO\n\n - Unittest framework in place, but lacking tests\n - Yahoo support\n - Outlook/Hotmail support\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ChristopherHaydenTodd/ctodd-python-lib-email", "keywords": "python,libraries,gmail,email", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "ctodd-python-lib-email", "package_url": "https://pypi.org/project/ctodd-python-lib-email/", "platform": "", "project_url": "https://pypi.org/project/ctodd-python-lib-email/", "project_urls": { "Homepage": "https://github.com/ChristopherHaydenTodd/ctodd-python-lib-email" }, "release_url": "https://pypi.org/project/ctodd-python-lib-email/1.0.1/", "requires_dist": [ "google-api-python-client (==1.7.9)", "oauthlib (==3.0.2)", "google-auth-oauthlib (==0.4.0)", "google-auth (==1.6.3)", "google-auth-httplib2 (==0.0.3)" ], "requires_python": ">3.6", "summary": "Python utilities used for interacting with email clients and sending emails", "version": "1.0.1" }, "last_serial": 5565002, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "b72a43a87f411ce15311546cb2f40bff", "sha256": "f6a402f81d1a0b8a37dde82c487924b921d5a009dc4a6e8685475cb594f934e6" }, "downloads": -1, "filename": "ctodd_python_lib_email-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b72a43a87f411ce15311546cb2f40bff", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">3.6", "size": 6796, "upload_time": "2019-07-21T22:25:35", "url": "https://files.pythonhosted.org/packages/75/bb/035778ac8d3df59371344cb10e5f42cf3e274889e2ad5b9de5e64e816c39/ctodd_python_lib_email-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7ad7b22d20f545bca5d3e697f50e4e6b", "sha256": "39b711b6db436521e4a64d4f064cab4f0fa1cb5a7d01d41a177a7ede702d4876" }, "downloads": -1, "filename": "ctodd-python-lib-email-1.0.0.tar.gz", "has_sig": false, "md5_digest": "7ad7b22d20f545bca5d3e697f50e4e6b", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6", "size": 6107, "upload_time": "2019-07-21T22:25:38", "url": "https://files.pythonhosted.org/packages/37/50/7727c0db04f0fa8c4c0950298a33aed3fbb9c743cda851d9cb49c4e8bfbf/ctodd-python-lib-email-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "8e592739680c77003a71c1d4bd5e31b0", "sha256": "894945a3836d5fa64416e2d4e45c1907d520dad2509d1cff7b24bbd789bf5a91" }, "downloads": -1, "filename": "ctodd_python_lib_email-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "8e592739680c77003a71c1d4bd5e31b0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">3.6", "size": 6840, "upload_time": "2019-07-21T23:27:18", "url": "https://files.pythonhosted.org/packages/a7/22/329e585f83cc58b85cd6b208dff90e116bdb9eb966239668fb76a2c0f2f4/ctodd_python_lib_email-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a7e5355a14efa235a938129074f23b63", "sha256": "cf86eed6361d6aeeb492687ac8554a0e99eab6b103db07575c64ced69499a6be" }, "downloads": -1, "filename": "ctodd-python-lib-email-1.0.1.tar.gz", "has_sig": false, "md5_digest": "a7e5355a14efa235a938129074f23b63", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6", "size": 6151, "upload_time": "2019-07-21T23:27:20", "url": "https://files.pythonhosted.org/packages/fa/37/f4592ff59f244e449837ae02bf65cca1134e8777f0c068f1d212061fabf7/ctodd-python-lib-email-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8e592739680c77003a71c1d4bd5e31b0", "sha256": "894945a3836d5fa64416e2d4e45c1907d520dad2509d1cff7b24bbd789bf5a91" }, "downloads": -1, "filename": "ctodd_python_lib_email-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "8e592739680c77003a71c1d4bd5e31b0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">3.6", "size": 6840, "upload_time": "2019-07-21T23:27:18", "url": "https://files.pythonhosted.org/packages/a7/22/329e585f83cc58b85cd6b208dff90e116bdb9eb966239668fb76a2c0f2f4/ctodd_python_lib_email-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a7e5355a14efa235a938129074f23b63", "sha256": "cf86eed6361d6aeeb492687ac8554a0e99eab6b103db07575c64ced69499a6be" }, "downloads": -1, "filename": "ctodd-python-lib-email-1.0.1.tar.gz", "has_sig": false, "md5_digest": "a7e5355a14efa235a938129074f23b63", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6", "size": 6151, "upload_time": "2019-07-21T23:27:20", "url": "https://files.pythonhosted.org/packages/fa/37/f4592ff59f244e449837ae02bf65cca1134e8777f0c068f1d212061fabf7/ctodd-python-lib-email-1.0.1.tar.gz" } ] }