From a658339b99a76c8270a9fe418eb3d3edc12a27b2 Mon Sep 17 00:00:00 2001 From: Audrey Roy Greenfeld Date: Fri, 27 May 2016 11:31:30 -0700 Subject: [PATCH] Switch from django-mailgun to django-anymail. Fix #539. --- README.rst | 3 ++- .../config/settings/production.py | 14 +++++++++++--- {{cookiecutter.project_slug}}/env.example | 1 - .../requirements/production.txt | 6 +++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index eece6391..14dcf207 100644 --- a/README.rst +++ b/README.rst @@ -32,7 +32,7 @@ Features * Registration via django-allauth_ * Comes with custom user model ready to go. * Grunt build for compass and livereload -* Basic e-mail configurations for sending emails via Mailgun_ +* Send emails via Anymail_ (using Mailgun_ by default, but switchable) * Media storage using Amazon S3 * Docker support using docker-compose_ for development and production * Procfile_ for deploying to Heroku @@ -64,6 +64,7 @@ Optional Integrations .. _Mailgun: https://mailgun.com/ .. _Whitenoise: https://whitenoise.readthedocs.io/ .. _Celery: http://www.celeryproject.org/ +.. _Anymail: https://github.com/anymail/django-anymail .. _MailHog: https://github.com/mailhog/MailHog .. _Sentry: https://getsentry.com .. _NewRelic: https://newrelic.com diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index cf35861f..00b4f1d2 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -155,12 +155,20 @@ INSTALLED_APPS = ('collectfast', ) + INSTALLED_APPS # ------------------------------------------------------------------------------ DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL', default='{{cookiecutter.project_name}} ') -EMAIL_BACKEND = 'django_mailgun.MailgunBackend' -MAILGUN_ACCESS_KEY = env('DJANGO_MAILGUN_API_KEY') -MAILGUN_SERVER_NAME = env('DJANGO_MAILGUN_SERVER_NAME') EMAIL_SUBJECT_PREFIX = env('DJANGO_EMAIL_SUBJECT_PREFIX', default='[{{cookiecutter.project_name}}] ') SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL) + +# Anymail with Mailgun +INSTALLED_APPS += ("anymail", ) +ANYMAIL = { + "MAILGUN_API_KEY": env('DJANGO_MAILGUN_API_KEY'), +} +EMAIL_BACKEND = "anymail.backends.mailgun.MailgunBackend" + {% if cookiecutter.use_newrelic == 'y'-%} + +# NEW RELIC +# ------------------------------------------------------------------------------ NEW_RELIC_LICENSE_KEY = env('NEW_RELIC_LICENSE_KEY') NEW_RELIC_APP_NAME = env('NEW_RELIC_APP_NAME') {%- endif %} diff --git a/{{cookiecutter.project_slug}}/env.example b/{{cookiecutter.project_slug}}/env.example index 68ff8a27..bbea38b2 100644 --- a/{{cookiecutter.project_slug}}/env.example +++ b/{{cookiecutter.project_slug}}/env.example @@ -9,7 +9,6 @@ DJANGO_AWS_ACCESS_KEY_ID= DJANGO_AWS_SECRET_ACCESS_KEY= DJANGO_AWS_STORAGE_BUCKET_NAME= DJANGO_MAILGUN_API_KEY= -DJANGO_MAILGUN_SERVER_NAME= DJANGO_SERVER_EMAIL= DJANGO_SECURE_SSL_REDIRECT=False DJANGO_ACCOUNT_ALLOW_REGISTRATION=True diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index b2308d36..5ac46e62 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -22,9 +22,9 @@ django-storages-redux==1.3.2 Collectfast==0.2.3 {%- endif %} -# Mailgun Support -# --------------- -django-mailgun==0.9.1 +# Email backends for Mailgun, Postmark, SendGrid and more +# ------------------------------------------------------- +django-anymail==0.3.1 {% if cookiecutter.use_sentry == "y" -%} # Raven is the Sentry client