Skip to main content

Ponddy email notification package

Project description

Ponddy Email Notification

Ponddy email notification package.

Installation

Install with pip

pip install ponddy-email-notification

Add this app to INSTALLED_APPS in settings.py

INSTALLED_APPS = [
    ...
    'email_notifications',
]

Usage

Migrate database

python manage.py migrate

Config email in settings.py check this at Django Docs

Setup urls in urls.py

from django.urls import path

from email_notifications.views import UnsubscribeView, UnsubscribeDoneView


urlpatterns = [
    ...
    path(
        'unsubscribe/<uuid:uuid>/',
        UnsubscribeView.as_view(),
        name='unsubscribe',
    ),
    path(
        'unsubscribe/done/',
        UnsubscribeDoneView.as_view(),
        name='unsubscribe_done',
    ),
]

Now you can send email notification with admin!!!

Also we support django template, your can get user with user and unsubscribe link with unsubscribe_link, for example

Subject -> 'Hi, {{ user.username }}
Message -> '............ unsubscribe with: {{ unsubscribe_link }}'
HTML message -> '........... <a href="{{ unsubscribe_link }}">Click here to unsubscribe</a>'

Customization

If you want to custom unsubscribe url name (default is unsubscribe), add UNSUBSCRIBE_URL in settings.py

UNSUBSCRIBE_URL='{{ your unsubscribe url name }}'

If you want to custom unsubscribe done url name (default is unsubscribe_done), config it in .as_view() function

UnsubscribeView.as_view(success_url='{{ your unsubscribe done url name }}')

If you want to custom templates, config it in .as_view() function

UnsubscribeView.as_view(template_name='{{ your template name}}')
UnsubscribeDoneView.as_view(template_name='{{ your template name}}')

Example

If you want to send notification with python script

from django.contrib.auth import get_user_model

from email_notifications.models import Notification
from email_notifications.services import send_notification


User = get_user_model()


notification = Notification.objects.create(
    subject='Hi, {{ user.username }}',
    message='............ unsubscribe with: {{ unsubscribe_link }}',
    html_message='........... <a href="{{ unsubscribe_link }}">Click here to unsubscribe</a>',
)
notification.users.add(User.objects.all())  # We will automatic exclude user, if unsubscribe or no email.
send_notification('http://127.0.0.1:8000', notification)

or in view

from django.contrib.auth import get_user_model
from django.http import HttpResponse

from email_notifications.models import Notification
from email_notifications.services import send_notification


User = get_user_model()


def example_view(request):
    notification = Notification.objects.create(
        subject='Hi, {{ user.username }}',
        message='............ unsubscribe with: {{ unsubscribe_link }}',
        html_message='........... <a href="{{ unsubscribe_link }}">Click here to unsubscribe</a>',
    )
    notification.users.add(User.objects.all())  # We will automatic exclude user, if unsubscribe or no email.
    send_notification(request.build_absolute_uri('/'), notification)
    return HttpResponse('ok')

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

ponddy-email-notification-0.0.6.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file ponddy-email-notification-0.0.6.tar.gz.

File metadata

  • Download URL: ponddy-email-notification-0.0.6.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for ponddy-email-notification-0.0.6.tar.gz
Algorithm Hash digest
SHA256 9a3194c5a41aa51dca622e1a625453ced10c6fad5f76d087e6e3f47246e6ba2d
MD5 2759fe9b07d909182aadba6a40455527
BLAKE2b-256 45121c8cfb656803dbcbb9d1ca727b5fd1eb1d851d1558ae02d0aefefc0b3ea0

See more details on using hashes here.

File details

Details for the file ponddy_email_notification-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: ponddy_email_notification-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for ponddy_email_notification-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 56c1f58497e1d9a50a1ab9dc303ffe39f0ab1e4d8560e14b8e3a12b2295f9a53
MD5 266e0d98d95df8ea768768fface7bc63
BLAKE2b-256 15aa36b588a1d14ab9e7b99ec030bcc117b020a09e905b09942f59ffab9ae356

See more details on using hashes here.

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