Email Service
Python package to quickly integrate different email services with your Application with just 3 lines of code.
Send Your email without caring about the backend code.
- GitHub:
- PyPI:
Usage
Install it with pip
$ pip install email-service
Email Integration
Save the API_KEY in the .env file as
SENDGRID_API_KEY=api_key
Import EmailHandler
>>> from email_service.email_handler import EmailHandler
Form the dictionary of data
data = {
"from_email": "Name WithSpace <from_email@gmail.com>", # Required
"subject": "This is the test for the Individual email", # Required
"reply_to_addresses": "email1@gmail.com",
"html_body": "<h1>Email Template for Individual email</h1>", # 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
"recipients": {
"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
>>> # For Individual Email
>>> send_email = EmailHandler()
>>> # For Bulk Email
>>> send_email = EmailHandler(email_type="BULK")
Sendgrid Integration
>>> # Send it using sendgrid
>>> response = send_email.sendgrid(data)
Response
status_code:
202: OK,
400: Error
message: Error or Success Message
Development
Setup
Clone the repository
$ git clone https://github.com/ramanaditya/email-service
Create a virtual environment using virtualenv or venv.
$ python -m venv venv
$ source venv/bin/activate
Upgrade pip
$ python -m pip install --upgrade pip
Install python packages
$ python -m pip install -r requirements.txt
Git Flow
Create new Branch from develop branch
$ git checkout -b develop origin/develop
$ git checkout -b feature_branch
Push the Code
$ git add file_which_was_changed
$ git commit -m "Commit Message"
$ git push -u origin feature_branch
Build Package for Local Testing
$ # 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
$ # Downloading latest version of setuptools
$ python -m pip install --user --upgrade setuptools wheel
$ python setup.py sdist bdist_wheel
Uploading to Test PyPI
$ # Upload to Test PyPI https://test.pypi.org/
$ python -m twine upload --repository testpypi dist/*
Download the package from Test PyPI
$ python -m pip install -i https://test.pypi.org/simple/ email-service
Check against the code
$ # 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
$ # Upload to PyPI https://pypi.org/
$ python -m twine upload dist/*
Download the package from Test PyPI
$ python -m pip install -i https://test.pypi.org/simple/ email-service
Issues
Issue No. |
Issue |
|---|---|
NOTE: Feel free to open issues. Make sure you follow the Issue Template provided.
Contribution Guidelines
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 🌟
Metadata
Release files for email-service 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| email-service-2.0.0.tar.gz | 14.9 kB | Without provenance | Details for email-service-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| email_service-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for email_service-2.0.0-py3-none-any.whl |
Total release size: 30.3 kB
Release files / email-service-2.0.0.tar.gz
| Download URL | email-service-2.0.0.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ebf4e7e36040a5609fa569648b2b293fe5fe06ca3e886daba278f311dfb6cb2
|
|
BLAKE2b-256 checksum How to use checksums |
aaae1d662282f901f1f7f1810c04b1e4c371d6d198a2e479542f77b4b13df8cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / email_service-2.0.0-py3-none-any.whl
| Download URL | email_service-2.0.0-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5c8293565be23831a031ac2d467ef4a5ba96f6fdee85a22b20c7b64b46121b8
|
|
BLAKE2b-256 checksum How to use checksums |
b40fd2d29579db72f43f7789bd142e52604b818dc32840c2f84a5848d3cc0410
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Security for email-service 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.