Skip to main content

Django Email Automation

Project description

https://img.shields.io/pypi/v/django_solar https://img.shields.io/pypi/pyversions/django_solar

Django email automation with cron.

Tested with :

  • django==3.0.9

Setup

Install with pip :

pip install django_solar

Add django_solar to django apps installed :

INSTALLED_APPS = [
    ...
    'django_solar',
]

Set Django email backend :

# Take a look at https://github.com/anymail/django-anymail

ANYMAIL = {
    "MAILJET_API_KEY": env.str('MAILJET_API_KEY'),
    "MAILJET_SECRET_KEY": env.str('MAILJET_SECRET_KEY'),
}
MAILJET_API_KEY = env.str('MAILJET_API_KEY')
MAILJET_SECRET_KEY = env.str('MAILJET_SECRET_KEY')

EMAIL_BACKEND = "anymail.backends.mailjet.EmailBackend"
DEFAULT_FROM_EMAIL = "hello@snoweb.fr"
SERVER_EMAIL = "hello@snoweb.fr"

Set django_solar context :

DS_CRON_HOUR = 1  # Period of cron in hours
DS_EVENT_MANAGER = "tests.manager.EventManager"  #  Class manager of events

Set cron command

0 * * * * python manage.py solar

Defines Events

Example of EventManger :

from django_solar import AEventManager, MailTemplate
from django_solar.models import Mail
from datetime import datetime


class EventManager(AEventManager):

    def event_something(self):
        Mail.objects.create(
            mail='test@exemple.com',  #  Receiver
            send_at=datetime.now(),  #  Datetime send
            html=MailTemplate.get(key='test'),  #  HTML of email
            subject="Test Django Solar"  #  Subject of email
        )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_solar-0.0.1.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

django_solar-0.0.1-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file django_solar-0.0.1.tar.gz.

File metadata

  • Download URL: django_solar-0.0.1.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9

File hashes

Hashes for django_solar-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8b67bc8540559b2f411349b9eb84a491fb7449ba3f05bb15874af0977987a29a
MD5 ca575c1ae33fdcc84f1396d8b9801e0f
BLAKE2b-256 a4a5b0e5bdf1a96c3a29d5ad85052674e090d43e0ec1ff0850df2c4d68cebb36

See more details on using hashes here.

Provenance

File details

Details for the file django_solar-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_solar-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9

File hashes

Hashes for django_solar-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe3c262ab652facd439fe3977fc94401158487c3c40722847d62eca0c0258c15
MD5 9bcda4a16142e9fb436085d9277d724a
BLAKE2b-256 2a805d705aa185014f9712f9840f4c0e9d23ac14ca260f8d41e06faeb27035e4

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page