You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Django module to easily send emails using django templates stored on database.
From box you can use it with django-celery for send background messages.
Also you have opportunity create reports from logs by mail categories and slug.
That app very simple to install and use on your projects.
Installation:
Using pip:
$ pip install django-db-mailer
Add the dbmail application to INSTALLED_APPS in your settings file (usually settings.py)
Sync database (./manage.py syncdb)
Usage examples
fromdbmail.modelsimportMailTemplatefromdbmailimportsend_db_mail# New dbmail templateMailTemplate.objects.create(
name="Site welcome template",
subject="Welcome",
message="Welcome to our site. We are glad to see you.",
slug="welcome",
is_html=False,
)
# Send message with created templatesend_db_mail(
# slug was defined on db templateslug='welcome',
# recipient can be list, or separated with comma or simple string# 'user1@example.com' or 'user1@example.com, user2@example.com' or ['user1@example.com', 'user2@example.com']recipient='user1@example.com',
# All *args params will be accessible on template context
{
'username': request.user.username,
'full_name': request.user.get_full_name(),
'signup_date': request.user.date_joined
},
# You can access to all model fields. For m2m and fk fields, you should use module_nameMyModel.objects.get(pk=1),
# Optional kwargs:# from_email='from@example.com'# cc=['cc@example.com'],# bcc=['bcc@example.com'],# user=User.objects.get(pk=1),# from_email='bcc@example.com',# attachments=[(filename, content, mimetype)],# headers={'Custom-Header':'Some value'},
)