Skip to main content

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

Metadata

Release files for email-core-lib 0.0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for email-core-lib 0.0.0.1
File Size Uploaded
email_core_lib-0.0.0.1.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for email-core-lib 0.0.0.1
File Interpreter ABI Platform
email_core_lib-0.0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / email_core_lib-0.0.0.1.tar.gz

Download URL email_core_lib-0.0.0.1.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8867fbc7d536ea16b2f2bcfd993caae01928eb168e8edd147f05b04b917fed5c
BLAKE2b-256 checksum
How to use checksums
c247eccfa18f066e667b09679281773606fa034ff3e0237a7939a2ad2c687125
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.17

Release files / email_core_lib-0.0.0.1-py3-none-any.whl

Download URL email_core_lib-0.0.0.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ac3dacaa0c0797f3cb2e20b12796bbfd5be4905360ddf02abfe47f640679487
BLAKE2b-256 checksum
How to use checksums
4a2615d25bde30aaf91abc3361fdb9f91ee3379ae8b427204937a6fe955933a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.17

Release history Release notifications | RSS feed

This release

0.0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page