Merge pull request #264 from burhan/feature/maildump

Use maildump instead of ConsoleEmailHandler
This commit is contained in:
Daniel Greenfeld 2015-07-16 07:27:15 -07:00
commit a848bde153
6 changed files with 49 additions and 2 deletions

View File

@ -28,6 +28,7 @@ Features
* Media storage using Amazon S3
* Serve static files from Amazon S3 or Whitenoise_ (optional)
* Pre configured Celery_ (optional)
* Integration with Maildump_ for local email testing (optional)
.. _Bootstrap: https://github.com/twbs/bootstrap
.. _AngularJS: https://github.com/angular/angular.js
@ -39,6 +40,7 @@ Features
.. _Mailgun: https://mailgun.com/
.. _Whitenoise: https://whitenoise.readthedocs.org/
.. _Celery: http://www.celeryproject.org/
.. _Maildump: https://github.com/ThiefMaster/maildump
Constraints

View File

@ -11,5 +11,6 @@
"year": "{{ cookiecutter.now[:4] }}",
"use_whitenoise": "y",
"use_celery": "n",
"use_maildump": "n",
"windows": "n"
}

View File

@ -21,7 +21,8 @@ module.exports = function (grunt) {
fonts: this.app + '/static/fonts',
images: this.app + '/static/images',
js: this.app + '/static/js',
manageScript: 'manage.py'
manageScript: 'manage.py',
{% if cookiecutter.use_maildump=="y" -%}mailserverpid: 'mailserver.pid',{%- endif %}
}
};
@ -82,7 +83,13 @@ module.exports = function (grunt) {
},
runDjango: {
cmd: 'python <%= paths.manageScript %> runserver'
}
},
{% if cookiecutter.use_maildump == "y" -%}runMailDump: {
cmd: 'maildump -p <%= paths.mailserverpid %>'
},
stopMailDump: {
cmd: 'maildump -p <%= paths.mailserverpid %> --stop'
},{%- endif %}
}
});
@ -98,4 +105,12 @@ module.exports = function (grunt) {
grunt.registerTask('default', [
'build'
]);
{% if cookiecutter.use_maildump == "y" -%}
grunt.registerTask('start-email-server', [
'bgShell:runMailDump'
]);
grunt.registerTask('stop-email-server', [
'bgShell:stopMailDump'
]);{%- endif %}
};

View File

@ -126,6 +126,28 @@ To run a celery worker:
Please note: For Celerys import magic to work, it is important *where* the celery commands are run. If you are in the same folder with *manage.py*, you should be right.
{% endif %}
{% if cookiecutter.use_maildump == "y" %}
Email Server
^^^^^^^^^^^^
In development, it is often nice to be able to see emails that are being sent from your application. For this purpose,
a Grunt task exists to start an instance of `maildump`_ which is a local SMTP server with an online interface.
.. _maildump: https://github.com/ThiefMaster/maildump
Make sure you have nodejs installed, and then type the following::
$ grunt start-email-server
This will start an email server. The project is setup to deliver to the email server by default. To view messages
that are sent by your application, open your browser to http://127.0.0.1:1080
To stop the email server::
$ grunt stop-email-server
The email server listens on 127.0.0.1:1025
{% endif %}
It's time to write the code!!!

View File

@ -25,8 +25,10 @@ SECRET_KEY = env("DJANGO_SECRET_KEY", default='CHANGEME!!!')
# ------------------------------------------------------------------------------
EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
{%if cookiecutter.use_maildump == "n" -%}
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND',
default='django.core.mail.backends.console.EmailBackend')
{%- endif %}
# CACHING
# ------------------------------------------------------------------------------

View File

@ -10,3 +10,8 @@ django-debug-toolbar==1.3.2
# improved REPL
ipdb==0.8.1
{% if cookiecutter.use_maildump == "y" -%}
# Enables better email testing
maildump==0.5.1
{%- endif %}