Email Core Lib
Project description
EmailCoreLib
EmailCoreLib uses Celery and MailChimp to receive data and send emails.
It uses Celery to listen to a queue and receive data over it, and MailChimp is used to fire emails using their Transactional Email service.
Services
- Send Emails using MailChimp
- Starts Celery Worker to handle requests
Config
core_lib:
email_core_lib:
amqp:
url:
protocol: amqp
username: ${oc.env:AMQP_USERNAME}
password: ${oc.env:AMQP_PASSWORD}
host: ${oc.env:AMQP_HOST}
port: ${oc.env:AMQP_PORT}
client:
_target_: email_core_lib.client.mailchimp_client.MailChimpClient
api_key: your_mailchimp_transactional_api_key
celery_main.py
This is the main file that will start the Celery worker and initialize the EmailCoreLib. As soon as a task is
dispatched for task.send it will use the MailchimpTransactional client to send the email.
EmailCoreLib
class EmailCoreLib(CoreLib):
def __init__(self, conf: DictConfig):
super().__init__()
self.config = conf
self.mailchimp = instantiate_config(self.config.core_lib.email_core_lib.client)
Uses CoreLib's instantiate_config that will instantiate the MailChimpClient from the config yaml.
MailChimp Client
This client will be initialized as soon as the Celery worker has started and the EmailCoreLib is initialized
Functions
def send(self, template_name: str, params: dict):
template_name (str): Name of the saved template in your MailChimp Transactional account
params (dict): A dict of variables as keys and their values that are saved in the template to be replaced.
Example
import hydra
from celery import Celery
hydra.initialize(config_path='config_path', caller_stack_depth=1)
cfg = hydra.compose('config.yaml')
app = Celery()
app.config_from_object(cfg.core_lib.email_core_lib.amqp.url)
app.autodiscover_tasks()
app.send_task('task.send',
['register_complete', {'email': 'john@example.com', 'plan': 'some plan'}]
)
License
Licenced under MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file email_core_lib-0.0.0.1.tar.gz.
File metadata
- Download URL: email_core_lib-0.0.0.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8867fbc7d536ea16b2f2bcfd993caae01928eb168e8edd147f05b04b917fed5c
|
|
| MD5 |
b4e7c53f8ea96fda9a9e8fcf351b7492
|
|
| BLAKE2b-256 |
c247eccfa18f066e667b09679281773606fa034ff3e0237a7939a2ad2c687125
|
File details
Details for the file email_core_lib-0.0.0.1-py3-none-any.whl.
File metadata
- Download URL: email_core_lib-0.0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ac3dacaa0c0797f3cb2e20b12796bbfd5be4905360ddf02abfe47f640679487
|
|
| MD5 |
57883b05f5a677e290cf1fce22250643
|
|
| BLAKE2b-256 |
4a2615d25bde30aaf91abc3361fdb9f91ee3379ae8b427204937a6fe955933a0
|