Merge pull request #259 from burhan/feature/mailgun-support

add support for mailgun, while dropping sendgrid support.
This commit is contained in:
Saurabh Kumar 2015-07-07 10:46:26 +05:30
commit 21a1062fae
4 changed files with 23 additions and 19 deletions

View File

@ -24,7 +24,7 @@ Features
* Registration via django-allauth_ * Registration via django-allauth_
* Procfile_ for deploying to Heroku * Procfile_ for deploying to Heroku
* Grunt build for compass and livereload * Grunt build for compass and livereload
* Basic e-mail configurations for send emails via SendGrid_ * Basic e-mail configurations for send emails via Mailgun_
* Media storage using Amazon S3 * Media storage using Amazon S3
* Serve static files from Amazon S3 or Whitenoise_ (optional) * Serve static files from Amazon S3 or Whitenoise_ (optional)
@ -35,7 +35,7 @@ Features
.. _django-allauth: https://github.com/pennersr/django-allauth .. _django-allauth: https://github.com/pennersr/django-allauth
.. _django-avatar: https://github.com/jezdez/django-avatar/ .. _django-avatar: https://github.com/jezdez/django-avatar/
.. _Procfile: https://devcenter.heroku.com/articles/procfile .. _Procfile: https://devcenter.heroku.com/articles/procfile
.. _SendGrid: https://sendgrid.com/ .. _Mailgun: https://mailgun.com/
.. _Whitenoise: https://whitenoise.readthedocs.org/ .. _Whitenoise: https://whitenoise.readthedocs.org/

View File

@ -30,16 +30,19 @@ DJANGO_SECURE_FRAME_DENY SECURE_FRAME_DENY n/a
DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS HSTS_INCLUDE_SUBDOMAINS n/a True DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS HSTS_INCLUDE_SUBDOMAINS n/a True
DJANGO_SESSION_COOKIE_HTTPONLY SESSION_COOKIE_HTTPONLY n/a True DJANGO_SESSION_COOKIE_HTTPONLY SESSION_COOKIE_HTTPONLY n/a True
DJANGO_SESSION_COOKIE_SECURE SESSION_COOKIE_SECURE n/a False DJANGO_SESSION_COOKIE_SECURE SESSION_COOKIE_SECURE n/a False
DJANGO_EMAIL_BACKEND EMAIL_BACKEND django.core.mail.backends.console.EmailBackend django.core.mail.backends.smtp.EmailBackend
DJANGO_EMAIL_HOST EMAIL_HOST localhost smtp.sendgrid.com
EMAIL_PORT EMAIL_PORT 1025 587
SENDGRID_USERNAME EMAIL_HOST_USER n/a raises error
SENDGRID_PASSWORD EMAIL_HOST_PASSWORD n/a raises error
DJANGO_DEFAULT_FROM_EMAIL DEFAULT_FROM_EMAIL n/a "{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>" DJANGO_DEFAULT_FROM_EMAIL DEFAULT_FROM_EMAIL n/a "{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>"
DJANGO_SERVER_EMAIL SERVER_EMAIL n/a "{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>"
EMAIL_SUBJECT_PREFIX EMAIL_SUBJECT_PREFIX n/a "[{{cookiecutter.project_name}}] " EMAIL_SUBJECT_PREFIX EMAIL_SUBJECT_PREFIX n/a "[{{cookiecutter.project_name}}] "
======================================= =========================== ============================================== ====================================================================== ======================================= =========================== ============================================== ======================================================================
* TODO: Add vendor-added settings in another table The following table lists settings and their defaults for third-party applications:
======================================= =========================== ============================================== ======================================================================
Environment Variable Django Setting Development Default Production Default
======================================= =========================== ============================================== ======================================================================
MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error
MAILGUN_SERVER_NAME MAILGUN_SERVER_NAME n/a raises error
======================================= =========================== ============================================== ======================================================================
Getting up and running Getting up and running
---------------------- ----------------------
@ -126,7 +129,7 @@ Run these commands to deploy the project to Heroku:
heroku pg:backups schedule DATABASE_URL heroku pg:backups schedule DATABASE_URL
heroku pg:promote DATABASE_URL heroku pg:promote DATABASE_URL
heroku addons:create sendgrid:starter heroku addons:create mailgun
heroku addons:create memcachier:dev heroku addons:create memcachier:dev
heroku config:set DJANGO_SECRET_KEY=RANDOM_SECRET_KEY_HERE heroku config:set DJANGO_SECRET_KEY=RANDOM_SECRET_KEY_HERE
@ -136,8 +139,7 @@ Run these commands to deploy the project to Heroku:
heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE
heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME=YOUR_AWS_S3_BUCKET_NAME_HERE heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME=YOUR_AWS_S3_BUCKET_NAME_HERE
heroku config:set SENDGRID_USERNAME=YOUR_SENDGRID_USERNAME heroku config:set MAILGUN_SERVER_NAME=YOUR_MALGUN_SERVER
heroku config:set SENDGRID_PASSWORD=YOUR_SENDGRID_PASSWORD
git push heroku master git push heroku master
heroku run python manage.py migrate heroku run python manage.py migrate
@ -180,8 +182,8 @@ You can then deploy by running the following commands.
ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_ACCESS_KEY_ID=YOUR_AWS_ID_HERE ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_ACCESS_KEY_ID=YOUR_AWS_ID_HERE
ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE
ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_STORAGE_BUCKET_NAME=YOUR_AWS_S3_BUCKET_NAME_HERE ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_STORAGE_BUCKET_NAME=YOUR_AWS_S3_BUCKET_NAME_HERE
ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} SENDGRID_USERNAME=YOUR_SENDGRID_USERNAME ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} MAILGUN_API_KEY=YOUR_MAILGUN_API_KEY
ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} SENDGRID_PASSWORD=YOUR_SENDGRID_PASSWORD ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} MAILGUN_SERVER_NAME=YOUR_MAILGUN_SERVER
ssh -t dokku@yourservername.com dokku run {{cookiecutter.repo_name}} python manage.py migrate ssh -t dokku@yourservername.com dokku run {{cookiecutter.repo_name}} python manage.py migrate
ssh -t dokku@yourservername.com dokku run {{cookiecutter.repo_name}} python manage.py createsuperuser ssh -t dokku@yourservername.com dokku run {{cookiecutter.repo_name}} python manage.py createsuperuser

View File

@ -102,13 +102,11 @@ INSTALLED_APPS = ('collectfast', ) + INSTALLED_APPS
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL', DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL',
default='{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>') default='{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>')
EMAIL_HOST = env("DJANGO_EMAIL_HOST", default='smtp.sendgrid.com') EMAIL_BACKEND = 'django_mailgun.MailgunBackend'
EMAIL_HOST_PASSWORD = env("SENDGRID_PASSWORD") MAILGUN_ACCESS_KEY = env('MAILGUN_API_KEY')
EMAIL_HOST_USER = env('SENDGRID_USERNAME') MAILGUN_SERVER_NAME = env('MAILGUN_SERVER_NAME')
EMAIL_PORT = env.int("EMAIL_PORT", default=587)
EMAIL_SUBJECT_PREFIX = env("EMAIL_SUBJECT_PREFIX", default='[{{cookiecutter.project_name}}] ') EMAIL_SUBJECT_PREFIX = env("EMAIL_SUBJECT_PREFIX", default='[{{cookiecutter.project_name}}] ')
EMAIL_USE_TLS = True SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', DEFAULT_FROM_EMAIL)
SERVER_EMAIL = EMAIL_HOST_USER
# TEMPLATE CONFIGURATION # TEMPLATE CONFIGURATION
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View File

@ -14,3 +14,7 @@ django-storages-redux==1.2.3
{% if cookiecutter.use_whitenoise != 'y' -%} {% if cookiecutter.use_whitenoise != 'y' -%}
Collectfast==0.2.3 Collectfast==0.2.3
{%- endif %} {%- endif %}
# Mailgun Support
# ---------------
django-mailgun==0.2.2