diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..0e86ea3
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,36 @@
+# http://editorconfig.org
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.{py,rst,ini}]
+indent_style = space
+indent_size = 4
+
+[*.py]
+max_line_length = 120
+multi_line_output = 3
+recursive = true
+skip = venv/
+include_trailing_comma = true
+force_grid_wrap = 0
+use_parentheses = true
+
+[*.yml]
+indent_style = space
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
+
+[{Makefile, *.bat}]
+indent_style = tab
+indent_size = 4
+
+[*.bat]
+end_of_line = crlf
diff --git a/.flake8 b/.flake8
new file mode 100644
index 0000000..cb5aa51
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,5 @@
+[flake8]
+max-line-length = 120
+exclude = .tox,.git,docs,venv,examples,build,dist,email_service.egg-info
+max-complexity = 18
+ignore = E203
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 37a7626..e15ce50 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -17,11 +17,11 @@ Please delete options that are not relevant.
# Checklist:
-- [ ] I have optimized the import, on pycharm it can be done using `ctrl + alt/option + o`
+- [ ] I have optimized the import, on Pycharm it can be done using `ctrl + alt/option + o`
- [ ] I have used Black for Code Formatting, this enhances code readability.
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
-- [ ] I have commented my code, particularly in hard-to-understand areas
+- [ ] I have commented on my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..6289635
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,33 @@
+name: CI
+
+on:
+ pull_request:
+ branches: [ "main" ]
+ paths-ignore: [ "docs/**" ]
+
+ push:
+ branches: [ "main" ]
+ paths-ignore: [ "docs/**" ]
+
+
+jobs:
+ flake8:
+ runs-on: ubuntu-latest
+
+ steps:
+
+ - name: Checkout Code Repository
+ uses: actions/checkout@v2
+
+ - name: Set up Python 3.9
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.9
+
+ - name: Install flake8
+ run: |
+ python -m pip install --upgrade pip
+ pip install flake8
+
+ - name: Lint with flake8
+ run: flake8
diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
index d0bed7d..ab86ac5 100644
--- a/.github/workflows/python-publish.yml
+++ b/.github/workflows/python-publish.yml
@@ -29,4 +29,4 @@ jobs:
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
- twine upload dist/*
+ python -m twine upload dist/*
diff --git a/.readthedocs.yml b/.readthedocs.yml
new file mode 100644
index 0000000..d1e3f47
--- /dev/null
+++ b/.readthedocs.yml
@@ -0,0 +1,10 @@
+version: 2
+
+sphinx:
+ configuration: docs/conf.py
+
+python:
+ version: 3.9
+ install:
+ - requirements: docs/requirements.txt
+ - requirements: requirements.txt
diff --git a/README.md b/README.md
deleted file mode 100644
index 6397c76..0000000
--- a/README.md
+++ /dev/null
@@ -1,175 +0,0 @@
-# Email Service
-
-Python package to quickly integrate different email services with your Application with just 3 lines of code.
-
-[](https://pypi.org/project/email-service/)
-[](https://pypi.org/project/email-service/)
-[](https://github.com/ramanaditya/email-service)
-[](https://github.com/ramanaditya/email-service)
-[](https://github.com/ramanaditya/email-service/releases/)
-[](https://github.com/ramanaditya/email-service/stargazers)
-[](https://github.com/ramanaditya/email-service/network/members)
-
-
-
-Send Your email without caring about the backend code.
-
-- GitHub: https://github.com/ramanaditya/email-service
-- PyPI: https://pypi.org/project/email-service/
-
-## Install it with pip
-```bash
-pip install email-service
-```
-
-## Email Integration
-> Save the `API_KEY` in the `.env` file as
->
-> SENDGRID_API_KEY=api_key
->
-
-### Import EmailHandler
-```python
-from email_service.email_handler import EmailHandler
-```
-
-### Form the dictionary of data
-```python
-data = {
- "from_email": "Name WithSpace ", # Required
- "subject": "This is the test for the Individual email", # Required
- "reply_to_addresses": "email1@gmail.com",
- "html_body": "Email Template for Individual email
", # Either of html_body or text_body is required
- "text_body": "Email Template for Individual email",
- "to_for_bulk": [{"name": "Name", "email": "email@gmail.com"},], # Required for Bulk Email
- "receipients": {
- "to": [{"name": "name1", "email": "email1@gmail.com"},], # Required
- "cc": [{"name": "name2", "email": "email2@google.com"},],
- "bcc": [{"name": "name3", "email": "email3@google.com"},],
- },
- "attachments": [
- "file_path (pdf)", "calender invite (ics)", "image_path (png/jpg/jpeg)"
- ]
-}
-
-```
-
-### Send the email
-```python
-
-# For Individual Email
-send_email = EmailHandler()
-
-# For Bulk Email
-send_email = EmailHandler(email_type="BULK")
-
-```
-
-### Sendgrid Integration
-
-```python
-# Send it using sendgrid
-response = send_email.sendgrid(data)
-
-```
-
-### Response
-```yaml
-status_code:
- 202: OK,
- 400: Error
-message: Error or Success Message
-```
-
-# Development
-
-## Setup
-[](https://github.com/ramanaditya/email-service/)
-[](https://github.com/ramanaditya/email-service/)
-
-1. Clone the repository
- ```bash
- git clone https://github.com/ramanaditya/email-service
- ```
-
-2. Create a virtual environment using virtualenv or venv.
- ```bash
- python -m venv venv
- source venv/bin/activate
- ```
-
-3. Upgrade pip
- ```bash
- python -m pip install --upgrade pip
- ```
-4. Install python packages
- ```bash
- python -m pip install -r requirements.txt
- ```
-
-5. Create new Branch from `develop` branch
- ```bash
- git checkout -b develop origin/develop
- git checkout -b feature_branch
- ```
-
-6. Generating distribution archives
- ```bash
- # Downloading latest version of setuptools
- python -m pip install --user --upgrade setuptools wheel
-
- python setup.py sdist bdist_wheel
- ```
-
-7. Uploading to Test PyPI
- ```bash
- # Upload to Test PyPI https://test.pypi.org/
- python -m twine upload --repository testpypi dist/*
- ```
-
-8. Download the package
- ```bash
- python -m pip install -i https://test.pypi.org/simple/ email-service
- ```
-
-9. Check against the code
- ```bash
- # Edit the file inside /example to have some valid data
- # export SENDGRID_API_KEY before running the script
- python individual_email.py # For individual email
- python bulk.py # For bulk email
- ```
-
-10. Push the Code
- ```bash
- git add file_which_was_changed
- git commit -m "Commit Message"
- git push -u origin feature_branch
- ```
-
-## Issues
-
-[](https://github.com/ramanaditya/email-service/issues)
-[](https://github.com/ramanaditya/email-service/pulls)
-[](https://github.com/ramanaditya/email-service/)
-
-> 1. Integrating Mailgun
-> 2. Integrating Amazon SES
-
-**NOTE**: **Feel free to [open issues](https://github.com/ramanaditya/email-service/issues/new/choose)**. Make sure you follow the Issue Template provided.
-
-## Contribution Guidelines
-
-[](https://github.com/ramanaditya/email-service/compare)
-[](https://github.com/ramanaditya/email-service/graphs/contributors)
-
-- Write clear meaningful git commit messages (Do read [this](http://chris.beams.io/posts/git-commit/)).
-- Make sure your PR's description contains GitHub's special keyword references that automatically close the related issue when the PR is merged. (Check [this](https://github.com/blog/1506-closing-issues-via-pull-requests) for more info)
-- When you make very very minor changes to a PR of yours (like for example fixing a text in button, minor changes requested by reviewers) make sure you squash your commits afterward so that you don't have an absurd number of commits for a very small fix. (Learn how to squash at [here](https://davidwalsh.name/squash-commits-git))
-
-- Please follow the [PR Template](https://github.com/ramanaditya/email-service/blob/master/.github/PULL_REQUEST_TEMPLATE.md) to create the PR.
-- Always open PR to `develop` branch.
-- Please read our [Code of Conduct](./CODE_OF_CONDUCT.md).
-- Refer [this](https://github.com/ramanaditya/email-service/blob/master/CONTRIBUTING.md) for more.
-
-> If you like this [repository](https://github.com/ramanaditya/email-service), support it by star :star2:
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..2f48a7b
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,304 @@
+###############
+Email Service
+###############
+
+Python package to quickly integrate different email services with your Application with just 3 lines of code.
+
+.. image:: https://img.shields.io/pypi/v/email-service.svg?color=2897A6
+ :target: https://pypi.org/project/email-service/
+ :alt: pypi
+.. image:: https://img.shields.io/pypi/pyversions/email-service.svg
+ :target: https://pypi.org/project/email-service/
+ :alt: python
+.. image:: https://img.shields.io/badge/license-MIT-red.svg?style=flat-square
+ :target: https://github.com/ramanaditya/email-service
+ :alt: license
+.. image:: https://img.shields.io/github/v/release/ramanaditya/email-service.svg
+ :target: https://github.com/ramanaditya/email-service/releases/
+ :alt: GitHub Release
+.. image:: https://img.shields.io/github/stars/ramanaditya/email-service.svg?logo=github
+ :target: https://github.com/ramanaditya/email-service/stargazers
+ :alt: GitHub stars
+.. image:: https://img.shields.io/github/forks/ramanaditya/email-service.svg?logo=github&color=teal
+ :target: https://github.com/ramanaditya/email-service/network/members
+ :alt: GitHub forks
+
+
+----
+
+
+Send Your email without caring about the backend code.
+
+:GitHub: `ramanaditya/email-service `__
+:PyPI: `pypi.org/project/email-service `__
+
+
+Usage
+======
+
+
+Install it with pip
+--------------------
+.. code-block:: console
+
+ $ pip install email-service
+
+
+Email Integration
+--------------------
+``Save the`` **API_KEY** ``in the`` **.env** ``file as``
+
+
+.. code-block:: text
+
+ SENDGRID_API_KEY=api_key
+
+
+Import EmailHandler
+--------------------
+.. code-block:: python
+
+ >>> from email_service.email_handler import EmailHandler
+
+
+Form the dictionary of data
+------------------------------
+.. code-block:: python
+
+ data = {
+ "from_email": "Name WithSpace ", # Required
+ "subject": "This is the test for the Individual email", # Required
+ "reply_to_addresses": "email1@gmail.com",
+ "html_body": "Email Template for Individual email
", # Either of html_body or text_body is required
+ "text_body": "Email Template for Individual email",
+ "to_for_bulk": [{"name": "Name", "email": "email@gmail.com"},], # Required for Bulk Email
+ "receipients": {
+ "to": [{"name": "name1", "email": "email1@gmail.com"},], # Required
+ "cc": [{"name": "name2", "email": "email2@google.com"},],
+ "bcc": [{"name": "name3", "email": "email3@google.com"},],
+ },
+ "attachments": [
+ "file_path (pdf)", "calender invite (ics)", "image_path (png/jpg/jpeg)"
+ ]
+ }
+
+
+Send the email
+-----------------
+.. code-block:: python
+
+ >>> # For Individual Email
+ >>> send_email = EmailHandler()
+
+ >>> # For Bulk Email
+ >>> send_email = EmailHandler(email_type="BULK")
+
+
+Sendgrid Integration
+----------------------
+.. code-block:: python
+
+ >>> # Send it using sendgrid
+ >>> response = send_email.sendgrid(data)
+
+
+Response
+-----------
+.. code-block:: yaml
+
+ status_code:
+ 202: OK,
+ 400: Error
+ message: Error or Success Message
+
+
+Development
+============
+
+.. image:: https://img.shields.io/github/languages/code-size/ramanaditya/email-service?logo=github
+ :target: https://github.com/ramanaditya/email-service/
+ :alt: GitHub code size in bytes
+.. image:: https://img.shields.io/github/repo-size/ramanaditya/email-service?logo=github
+ :target: https://github.com/ramanaditya/email-service/
+ :alt: GitHub repo size
+.. image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square
+ :target: https://github.com/ramanaditya/email-service
+ :alt: black
+
+
+Setup
+-------
+
+
+Clone the repository
+^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ git clone https://github.com/ramanaditya/email-service
+
+
+Create a virtual environment using virtualenv or venv.
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ python -m venv venv
+ $ source venv/bin/activate
+
+
+Upgrade pip
+^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ python -m pip install --upgrade pip
+
+
+Install python packages
+^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ python -m pip install -r requirements.txt
+
+
+Git Flow
+----------
+
+
+Create new Branch from `develop` branch
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ git checkout -b develop origin/develop
+ $ git checkout -b feature_branch
+
+
+Push the Code
+^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ git add file_which_was_changed
+ $ git commit -m "Commit Message"
+ $ git push -u origin feature_branch
+
+
+Build Package for Local Testing
+================================
+.. code-block:: console
+
+ $ # Build the package
+ $ python setup.py build
+
+ $ # Install the package
+ $ python setup.py install
+
+
+PyPI
+-----
+
+
+This is just for the reference and need not to be run,
+If you want to run these scripts, please take a note of this
+
+* For testing, we maintain the test package at `testpypi `__
+* PyPI or Test PyPI, does not accept same file name, you can change the file name or version in the `./setup.py `__
+* You will be prompted to enter
+ - Either username and password
+ - or, username as "__token__" and password as token (can be generated from the pypi website)
+* It will be uploaded to your pypi or testpypi account
+
+
+Generating distribution archives
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ # Downloading latest version of setuptools
+ $ python -m pip install --user --upgrade setuptools wheel
+
+ $ python setup.py sdist bdist_wheel
+
+
+Uploading to Test PyPI
+^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ # Upload to Test PyPI https://test.pypi.org/
+ $ python -m twine upload --repository testpypi dist/*
+
+
+Download the package from Test PyPI
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ python -m pip install -i https://test.pypi.org/simple/ email-service
+
+
+Check against the code
+^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ # Edit the file inside /example to have some valid data
+ $ # export SENDGRID_API_KEY before running the script
+ $ python individual_email.py # For individual email
+ $ python bulk.py # For bulk email
+
+
+Uploading to PyPI
+^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ # Upload to PyPI https://pypi.org/
+ $ python -m twine upload dist/*
+
+
+Download the package from Test PyPI
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ python -m pip install -i https://test.pypi.org/simple/ email-service
+
+
+Issues
+========
+
+
+.. image:: https://img.shields.io/github/issues/ramanaditya/email-service?logo=github
+ :target: https://github.com/ramanaditya/email-service/issues
+ :alt: GitHub issues
+.. image:: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat&logo=git&logoColor=white
+ :target: https://github.com/ramanaditya/email-service/pulls
+ :alt: PRs Welcome
+.. image:: https://img.shields.io/github/last-commit/ramanaditya/email-service?logo=github
+ :target: https://github.com/ramanaditya/email-service/
+ :alt: GitHub last commit
+
+
++-------------+-------------+
+| Issue No. | Issue |
++=============+=============+
+| | |
++-------------+-------------+
+
+
+**NOTE**: **Feel free to** `open issues `__. Make sure you follow the Issue Template provided.
+
+
+Contribution Guidelines
+========================
+
+.. image:: https://img.shields.io/github/issues-pr-raw/ramanaditya/email-service?logo=git&logoColor=white
+ :target: https://github.com/ramanaditya/email-service/compare
+ :alt: GitHub pull requests
+.. image:: https://img.shields.io/github/contributors/ramanaditya/email-service?logo=github
+ :target: https://github.com/ramanaditya/email-service/graphs/contributors
+ :alt: GitHub contributors
+
+
+* Write clear meaningful git commit messages (Do read `this `__).
+* Make sure your PR's description contains GitHub's special keyword references that automatically close the related issue when the PR is merged. (Check `this `__ for more info)
+* When you make very very minor changes to a PR of yours (like for example fixing a text in button, minor changes requested by reviewers) make sure you squash your commits afterward so that you don't have an absurd number of commits for a very small fix. (Learn how to squash at `here `__)
+* Please follow the `PR Template `__ to create the PR.
+* Always open PR to ``develop`` branch.
+* Please read our `Code of Conduct `__.
+* Refer `this `__ for more.
+
+
+``If you`` ❤️ ``this`` `repository `__ ``, support it by star 🌟``
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..644e6e7
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,30 @@
+# Minimal makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line, and also
+# from the environment for the first two.
+SPHINXOPTS ?=
+SPHINXBUILD ?= sphinx-build -c .
+SOURCEDIR = .
+BUILDDIR = ./_build
+PACKAGE = ../email_service
+
+
+.PHONY: help livehtml apidocs Makefile
+
+# Put it first so that "make" without argument is like "make help".
+help:
+ @$(SPHINXBUILD) help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+# Build, watch and serve docs with live reload
+livehtml:
+ sphinx-autobuild -b html --open-browser --port 7000 --watch $(PACKAGE) -c . $(SOURCEDIR) $(BUILDDIR)/html
+
+# Outputs rst files from application code
+apidocs:
+ sphinx-apidoc -o $(SOURCEDIR)/api $(PACKAGE)
+
+# Catch-all target: route all unknown targets to Sphinx using the new
+# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
+%: Makefile
+ @$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
diff --git a/docs/__init__.py b/docs/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..8a66e1f
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,96 @@
+# Configuration file for the Sphinx documentation builder.
+#
+# This file only contains a selection of the most common options. For a full
+# list see the documentation:
+# https://www.sphinx-doc.org/en/master/usage/configuration.html
+
+# -- Path setup --------------------------------------------------------------
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+
+from datetime import date
+from pathlib import Path
+
+ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent
+PACKAGE_DIR = ROOT_DIR / "email_service"
+DOCS_DIR = ROOT_DIR / "email_service"
+version_file_path = PACKAGE_DIR / "version.py"
+
+code_obj = compile(version_file_path.read_text(), version_file_path, "exec")
+__version__ = dict()
+exec(code_obj, __version__)
+version = __version__["__version__"]
+
+# -- Project information -----------------------------------------------------
+
+project = "Email Service"
+copyright = """2020, Aditya Raman"""
+author = "Aditya Raman"
+
+# The full version, including alpha/beta/rc tags
+version = release = f"v{version}"
+today = str(date.today())
+language = "en"
+
+# -- General configuration ---------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ "sphinx_rtd_theme",
+ "sphinx.ext.autodoc",
+ "sphinx.ext.napoleon",
+ "sphinx.ext.viewcode",
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ["_templates"]
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+# This pattern also affects html_static_path and html_extra_path.
+exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
+
+# -- Options for HTML output -------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+#
+html_theme = "sphinx_rtd_theme" # alternate: "alabaster"
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ["_static"]
+# These paths are either relative to html_static_path
+# or fully qualified paths (eg. https://...)
+# html_css_files = []
+#
+# html_style = ""
+
+master_doc = "index"
+
+latex_elements = {
+ # The paper size ('letterpaper' or 'a4paper').
+ #
+ "papersize": "a4paper",
+ # The font size ('10pt', '11pt' or '12pt').
+ #
+ # 'pointsize': '10pt',
+ # Additional stuff for the LaTeX preamble.
+ #
+ "preamble": "\\addto\\captionsenglish{\\renewcommand{\\contentsname}{Table of contents}}",
+ # Latex figure (float) alignment
+ #
+ # 'figure_align': 'htbp',
+}
+latex_show_urls = "footnote"
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+add_module_names = False
+add_function_parentheses = False
+show_authors = True
diff --git a/docs/email-service.rst b/docs/email-service.rst
new file mode 100644
index 0000000..2f48a7b
--- /dev/null
+++ b/docs/email-service.rst
@@ -0,0 +1,304 @@
+###############
+Email Service
+###############
+
+Python package to quickly integrate different email services with your Application with just 3 lines of code.
+
+.. image:: https://img.shields.io/pypi/v/email-service.svg?color=2897A6
+ :target: https://pypi.org/project/email-service/
+ :alt: pypi
+.. image:: https://img.shields.io/pypi/pyversions/email-service.svg
+ :target: https://pypi.org/project/email-service/
+ :alt: python
+.. image:: https://img.shields.io/badge/license-MIT-red.svg?style=flat-square
+ :target: https://github.com/ramanaditya/email-service
+ :alt: license
+.. image:: https://img.shields.io/github/v/release/ramanaditya/email-service.svg
+ :target: https://github.com/ramanaditya/email-service/releases/
+ :alt: GitHub Release
+.. image:: https://img.shields.io/github/stars/ramanaditya/email-service.svg?logo=github
+ :target: https://github.com/ramanaditya/email-service/stargazers
+ :alt: GitHub stars
+.. image:: https://img.shields.io/github/forks/ramanaditya/email-service.svg?logo=github&color=teal
+ :target: https://github.com/ramanaditya/email-service/network/members
+ :alt: GitHub forks
+
+
+----
+
+
+Send Your email without caring about the backend code.
+
+:GitHub: `ramanaditya/email-service `__
+:PyPI: `pypi.org/project/email-service `__
+
+
+Usage
+======
+
+
+Install it with pip
+--------------------
+.. code-block:: console
+
+ $ pip install email-service
+
+
+Email Integration
+--------------------
+``Save the`` **API_KEY** ``in the`` **.env** ``file as``
+
+
+.. code-block:: text
+
+ SENDGRID_API_KEY=api_key
+
+
+Import EmailHandler
+--------------------
+.. code-block:: python
+
+ >>> from email_service.email_handler import EmailHandler
+
+
+Form the dictionary of data
+------------------------------
+.. code-block:: python
+
+ data = {
+ "from_email": "Name WithSpace ", # Required
+ "subject": "This is the test for the Individual email", # Required
+ "reply_to_addresses": "email1@gmail.com",
+ "html_body": "Email Template for Individual email
", # Either of html_body or text_body is required
+ "text_body": "Email Template for Individual email",
+ "to_for_bulk": [{"name": "Name", "email": "email@gmail.com"},], # Required for Bulk Email
+ "receipients": {
+ "to": [{"name": "name1", "email": "email1@gmail.com"},], # Required
+ "cc": [{"name": "name2", "email": "email2@google.com"},],
+ "bcc": [{"name": "name3", "email": "email3@google.com"},],
+ },
+ "attachments": [
+ "file_path (pdf)", "calender invite (ics)", "image_path (png/jpg/jpeg)"
+ ]
+ }
+
+
+Send the email
+-----------------
+.. code-block:: python
+
+ >>> # For Individual Email
+ >>> send_email = EmailHandler()
+
+ >>> # For Bulk Email
+ >>> send_email = EmailHandler(email_type="BULK")
+
+
+Sendgrid Integration
+----------------------
+.. code-block:: python
+
+ >>> # Send it using sendgrid
+ >>> response = send_email.sendgrid(data)
+
+
+Response
+-----------
+.. code-block:: yaml
+
+ status_code:
+ 202: OK,
+ 400: Error
+ message: Error or Success Message
+
+
+Development
+============
+
+.. image:: https://img.shields.io/github/languages/code-size/ramanaditya/email-service?logo=github
+ :target: https://github.com/ramanaditya/email-service/
+ :alt: GitHub code size in bytes
+.. image:: https://img.shields.io/github/repo-size/ramanaditya/email-service?logo=github
+ :target: https://github.com/ramanaditya/email-service/
+ :alt: GitHub repo size
+.. image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square
+ :target: https://github.com/ramanaditya/email-service
+ :alt: black
+
+
+Setup
+-------
+
+
+Clone the repository
+^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ git clone https://github.com/ramanaditya/email-service
+
+
+Create a virtual environment using virtualenv or venv.
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ python -m venv venv
+ $ source venv/bin/activate
+
+
+Upgrade pip
+^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ python -m pip install --upgrade pip
+
+
+Install python packages
+^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ python -m pip install -r requirements.txt
+
+
+Git Flow
+----------
+
+
+Create new Branch from `develop` branch
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ git checkout -b develop origin/develop
+ $ git checkout -b feature_branch
+
+
+Push the Code
+^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ git add file_which_was_changed
+ $ git commit -m "Commit Message"
+ $ git push -u origin feature_branch
+
+
+Build Package for Local Testing
+================================
+.. code-block:: console
+
+ $ # Build the package
+ $ python setup.py build
+
+ $ # Install the package
+ $ python setup.py install
+
+
+PyPI
+-----
+
+
+This is just for the reference and need not to be run,
+If you want to run these scripts, please take a note of this
+
+* For testing, we maintain the test package at `testpypi `__
+* PyPI or Test PyPI, does not accept same file name, you can change the file name or version in the `./setup.py `__
+* You will be prompted to enter
+ - Either username and password
+ - or, username as "__token__" and password as token (can be generated from the pypi website)
+* It will be uploaded to your pypi or testpypi account
+
+
+Generating distribution archives
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ # Downloading latest version of setuptools
+ $ python -m pip install --user --upgrade setuptools wheel
+
+ $ python setup.py sdist bdist_wheel
+
+
+Uploading to Test PyPI
+^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ # Upload to Test PyPI https://test.pypi.org/
+ $ python -m twine upload --repository testpypi dist/*
+
+
+Download the package from Test PyPI
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ python -m pip install -i https://test.pypi.org/simple/ email-service
+
+
+Check against the code
+^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ # Edit the file inside /example to have some valid data
+ $ # export SENDGRID_API_KEY before running the script
+ $ python individual_email.py # For individual email
+ $ python bulk.py # For bulk email
+
+
+Uploading to PyPI
+^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ # Upload to PyPI https://pypi.org/
+ $ python -m twine upload dist/*
+
+
+Download the package from Test PyPI
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. code-block:: console
+
+ $ python -m pip install -i https://test.pypi.org/simple/ email-service
+
+
+Issues
+========
+
+
+.. image:: https://img.shields.io/github/issues/ramanaditya/email-service?logo=github
+ :target: https://github.com/ramanaditya/email-service/issues
+ :alt: GitHub issues
+.. image:: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat&logo=git&logoColor=white
+ :target: https://github.com/ramanaditya/email-service/pulls
+ :alt: PRs Welcome
+.. image:: https://img.shields.io/github/last-commit/ramanaditya/email-service?logo=github
+ :target: https://github.com/ramanaditya/email-service/
+ :alt: GitHub last commit
+
+
++-------------+-------------+
+| Issue No. | Issue |
++=============+=============+
+| | |
++-------------+-------------+
+
+
+**NOTE**: **Feel free to** `open issues `__. Make sure you follow the Issue Template provided.
+
+
+Contribution Guidelines
+========================
+
+.. image:: https://img.shields.io/github/issues-pr-raw/ramanaditya/email-service?logo=git&logoColor=white
+ :target: https://github.com/ramanaditya/email-service/compare
+ :alt: GitHub pull requests
+.. image:: https://img.shields.io/github/contributors/ramanaditya/email-service?logo=github
+ :target: https://github.com/ramanaditya/email-service/graphs/contributors
+ :alt: GitHub contributors
+
+
+* Write clear meaningful git commit messages (Do read `this `__).
+* Make sure your PR's description contains GitHub's special keyword references that automatically close the related issue when the PR is merged. (Check `this `__ for more info)
+* When you make very very minor changes to a PR of yours (like for example fixing a text in button, minor changes requested by reviewers) make sure you squash your commits afterward so that you don't have an absurd number of commits for a very small fix. (Learn how to squash at `here `__)
+* Please follow the `PR Template `__ to create the PR.
+* Always open PR to ``develop`` branch.
+* Please read our `Code of Conduct `__.
+* Refer `this `__ for more.
+
+
+``If you`` ❤️ ``this`` `repository `__ ``, support it by star 🌟``
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..5897f43
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,22 @@
+.. Email Service documentation master file, created by
+ sphinx-quickstart.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to Email Service's documentation!
+======================================================================
+
+.. toctree::
+ :maxdepth: 2
+ :caption: Contents:
+
+ email-service
+
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
diff --git a/docs/make.bat b/docs/make.bat
new file mode 100644
index 0000000..30e294e
--- /dev/null
+++ b/docs/make.bat
@@ -0,0 +1,46 @@
+@ECHO OFF
+
+pushd %~dp0
+
+REM Command file for Sphinx documentation
+
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build -c .
+)
+set SOURCEDIR=_source
+set BUILDDIR=_build
+set PACKAGE= ../email_service
+
+if "%1" == "" goto help
+
+%SPHINXBUILD% >NUL 2>NUL
+if errorlevel 9009 (
+ echo.
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+ echo.installed, then set the SPHINXBUILD environment variable to point
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
+ echo.may add the Sphinx directory to PATH.
+ echo.
+ echo.Install sphinx-autobuild for live serving.
+ echo.If you don't have Sphinx installed, grab it from
+ echo.http://sphinx-doc.org/
+ exit /b 1
+)
+
+%SPHINXBUILD% -b %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
+goto end
+
+:livehtml
+sphinx-autobuild -b html --open-browser -p 7000 --watch %PACKAGE% -c . %SOURCEDIR% %BUILDDIR%/html
+GOTO :EOF
+
+:apidocs
+sphinx-apidoc -o %SOURCEDIR%/api %PACKAGE%
+GOTO :EOF
+
+:help
+%SPHINXBUILD% -b help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
+
+:end
+popd
diff --git a/docs/requirements.txt b/docs/requirements.txt
new file mode 100644
index 0000000..edf4b3b
--- /dev/null
+++ b/docs/requirements.txt
@@ -0,0 +1,5 @@
+# Documentation
+# ------------------------------------------------------------------------------
+sphinx==3.4.1 # https://github.com/sphinx-doc/sphinx
+sphinx-autobuild==2020.9.1 # https://github.com/GaretJax/sphinx-autobuild
+sphinx-rtd-theme==0.5.0 # https://github.com/readthedocs/sphinx_rtd_theme
diff --git a/email_service/sendgrid/sendgrid.py b/email_service/sendgrid/sendgrid.py
index b12928c..cadc239 100644
--- a/email_service/sendgrid/sendgrid.py
+++ b/email_service/sendgrid/sendgrid.py
@@ -1,7 +1,22 @@
import base64
from sendgrid import SendGridAPIClient
-from sendgrid.helpers.mail import *
+from sendgrid.helpers.mail import (
+ Attachment,
+ Bcc,
+ Cc,
+ Content,
+ Disposition,
+ FileContent,
+ FileName,
+ FileType,
+ From,
+ Mail,
+ MimeType,
+ ReplyTo,
+ Subject,
+ To,
+)
from email_service.utils.clean_data import CleanData
from email_service.utils.constants import ATTACHMENT_FILE_TYPES
@@ -85,10 +100,10 @@ def send_email(self, message) -> dict:
}
# For accepting Other errors
- except:
+ except Exception:
status = {
"status_code": 400,
- "message": f"Something Went Wrong",
+ "message": "Something Went Wrong",
}
return status
diff --git a/email_service/version.py b/email_service/version.py
new file mode 100644
index 0000000..78212a0
--- /dev/null
+++ b/email_service/version.py
@@ -0,0 +1,11 @@
+import os
+from datetime import datetime
+
+import pytz
+
+__version__ = "1.1.0"
+
+# Add datetime.now() for test PyPI to skip conflicts in file name
+test_version = os.environ.get("TESTPYPI", default=False)
+if test_version:
+ __version__ += "." + datetime.now(pytz.timezone("UTC")).strftime("%y.%m.%d.%H.%M")
diff --git a/requirements.txt b/requirements.txt
index c07595e..9a5b944 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,4 +4,5 @@ sendgrid==6.4.8 # https://github.com/sendgrid/sendgrid-python/
# Others
# =======================================================================
-pytz==2020.5 # https://github.com/stub42/pytz
+pytz==2020.5 # https://github.com/stub42/pytz
+flake8==3.8.4 # https://github.com/PyCQA/flake8
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..0c9e0fc
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,2 @@
+[metadata]
+license_file = LICENSE
diff --git a/setup.py b/setup.py
index ab4f322..2fcf573 100644
--- a/setup.py
+++ b/setup.py
@@ -1,37 +1,38 @@
#!/usr/bin/env python
-
-import os
-from datetime import datetime
-
-import pytz
+from collections import OrderedDict
+from pathlib import Path
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup
-with open("README.md", "r") as readme_file:
- long_description = readme_file.read()
-version = "1.0.0"
+ROOT_DIR = Path(__file__).resolve(strict=True).parent
+PACKAGE_DIR = ROOT_DIR / "email_service"
-# Add datetime.now() for test PyPI to skip conflicts in file name
-test_version = os.environ.get("TESTPYPI", default=False)
-if test_version:
- version += "." + datetime.now(pytz.timezone("UTC")).strftime("%y.%m.%d.%H") + ""
+with open(PACKAGE_DIR / "version.py", encoding="utf-8") as version_file:
+ code_obj = compile(version_file.read(), PACKAGE_DIR / "version.py", "exec")
+ __version__ = dict()
+ exec(code_obj, __version__)
+ version = __version__["__version__"]
+
+with open("README.rst", "r") as readme_file:
+ long_description = readme_file.read()
setup(
name="email-service",
version=version,
- License="MIT License",
+ license="MIT License",
author="Aditya Raman",
author_email="adityaraman96@gmail.com",
description="Package to integrate different email services with your application "
"in just three lines of code.",
long_description=long_description,
- long_description_content_type="text/markdown",
+ long_description_content_type="text/x-rst",
url="https://github.com/ramanaditya/email-service",
packages=find_packages(),
+ zip_safe=False,
install_requires=["sendgrid==6.4.8"],
classifiers=[
"Development Status :: 4 - Beta",
@@ -48,4 +49,10 @@
keywords=(
"python, email, sendgrid, amazon, ses, mailgun, project, email client, setup.py"
),
+ project_urls=OrderedDict(
+ [
+ ("Source", "https://github.com/ramanaditya/email-service"),
+ ("Tracker", "https://github.com/ramanaditya/email-service/issues"),
+ ]
+ ),
)