Welcome to django mail admin’s documentation!¶
Contents:
django mail admin¶
The one and only django app to receive & send mail with templates and multiple configurations.
Work In progress!¶
Features¶
- Everything django-mailbox has
- Everything django-post-office has
- Database configurations - activate an outbox to send from, activate a mailbox to receive from
- Templates
- Translatable
- Mailings - using send_many() or ‘cc’ and ‘bcc’ or even recipients - all of those accept comma-separated lists of emails
Dependencies¶
Documentation¶
The full documentation is at https://django_mail_admin.readthedocs.io.
Quickstart¶
Q: What versions of Django/Python are supported? A: Take a look at https://travis-ci.org/delneg/django_mail_admin
Install django mail admin:
pip install django_mail_admin
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'django_mail_admin',
...
)
Run
migrate
:python manage.py migrate
Set
django_mail_admin.backends.CustomEmailBackend
as yourEMAIL_BACKEND
in django’ssettings.py
:EMAIL_BACKEND = 'django_mail_admin.backends.CustomEmailBackend'
Custom Email Backends¶
By default, django_mail_admin
uses custom Email Backends that looks up for Outbox models in database. If you want to
use a different backend, you can do so by configuring BACKENDS
, though you will not be able to use Outboxes and will have to set EMAIL_HOST etc. in django’s settings.py
.
For example if you want to use django-ses:
DJANGO_MAIL_ADMIN = {
'BACKENDS': {
'default': 'django_mail_admin.backends.CustomEmailBackend',
'smtp': 'django.core.mail.backends.smtp.EmailBackend',
'ses': 'django_ses.SESBackend',
}
}
You can then choose what backend you want to use when sending mail:
# If you omit `backend_alias` argument, `default` will be used
mail.send(
'from@example.com',
['recipient@example.com'],
subject='Hello',
)
# If you want to send using `ses` backend
mail.send(
'from@example.com',
['recipient@example.com'],
subject='Hello',
backend='ses',
)
Optional requirements¶
- django_admin_row_actions for some useful actions in the admin interface
- requests & social_django for Gmail
FAQ¶
Q: Why did you write this?
A: In order to get both email sending & receiving you’ll have to install post_office AND django_mailbox. Even if you do, you’ll have to work on admin interface for it to look prettier, somehow link replies properly etc. So I’ve decided merging those two and clearing the mess in between them as well as adding some other useful features.
Q: Why did you remove support for Python 2?
A: Because f*ck python2. Really, it’s been 9 (NINE!) years since it came out. Go ahead and check out https://github.com/brettcannon/caniusepython3
Q: Why is it named django_mail_admin, what does it have to do with admin ?
A: Well, the first version of this package (which was living just in a really large admin.py) was used for easy mail management using standard Django admin interface.
Q: What languages are available?
A: Currently there’s Russian and English languages available. Feel free to add yours:
source <YOURVIRTUALENV>/bin/activate
python manage.py makemessages -l YOUR_LOCALE -i venv
python manage.py compilemessages -l YOUR_LOCALE
Q: Why did you delete support for multi-lingual templates?
A: Well, we have django-model-translations for that. You can easily fork this app and override EmailTemplate model (models/templates.py) accordingly. I think there’s no need for such an overhead in a mail-related app.
Q: I don’t want my outgoing emails to be queued for sending after saving them in the admin interface, what do i do?
A: Just override OutgoingEmailAdmin’s save_model method.
Q: Can i get in touch with you? I want a new feature to be implemented/bug fixed!
A: Feel free to reach me out using issues and pull requests, I’ll review them all and answer when I can.
Running Tests¶
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox
Installation¶
At the command line:
$ easy_install django_mail_admin
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv django_mail_admin
$ pip install django_mail_admin
Usage¶
To use django mail admin in a project, add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'django_mail_admin',
...
)
Add django mail admin’s URL patterns:
from django_mail_admin import urls as django_mail_admin_urls
urlpatterns = [
...
url(r'^', include(django_mail_admin_urls)),
...
]
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/delneg/django_mail_admin/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.
Write Documentation¶
django mail admin could always use more documentation, whether as part of the official django mail admin docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/delneg/django_mail_admin/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up django_mail_admin for local development.
Fork the django_mail_admin repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/django_mail_admin.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv django_mail_admin $ cd django_mail_admin/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 django_mail_admin tests $ python setup.py test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check https://travis-ci.org/delneg/django_mail_admin/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Denis Bobrov <delneg@yandex.ru>
Contributors¶
None yet. Why not be the first?