Package to integrate different email services with your application in just three lines of code.
Project description
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.
Install it with pip
pip install email-service
Email Integration
Save the
API_KEY
in the.env
file asSENDGRID_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
"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
# 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
-
Create new Branch from
develop
branchgit checkout -b develop origin/develop git checkout -b feature_branch
-
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
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
-
Push the Code
git add file_which_was_changed git commit -m "Commit Message" git push -u origin feature_branch
Issues
- Integrating Mailgun
- Integrating Amazon SES
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 like this repository, support it by star :star2:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for email_service-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 620d71baeeb691853f538e9c78c7d98beca558cbb633bad9c3f71b08192389cd |
|
MD5 | b01df365001f0ca9b8866ef8942d9ac0 |
|
BLAKE2b-256 | 3d2dba5a6fb21b400570f82d3c74dcb9962697157717fd3e2b1f7cc451f60aab |