From 005dd8c29664594ad789680e3262eac464747c59 Mon Sep 17 00:00:00 2001 From: Tom Atkins Date: Mon, 16 Nov 2015 11:45:29 +0000 Subject: [PATCH 1/4] Replace Maildump with MailHog --- README.rst | 22 ++++++++++++------- cookiecutter.json | 2 +- docs/developing-locally.rst | 11 ++++++++-- docs/project-generation-options.rst | 10 ++++----- tests/test_cookiecutter_generation.py | 2 +- {{cookiecutter.repo_name}}/Gruntfile.js | 20 +++++------------ {{cookiecutter.repo_name}}/README.rst | 21 ++++++++---------- .../config/settings/local.py | 2 +- .../requirements/local.txt | 12 ---------- 9 files changed, 46 insertions(+), 56 deletions(-) diff --git a/README.rst b/README.rst index 3a607447..bf20b711 100644 --- a/README.rst +++ b/README.rst @@ -32,14 +32,20 @@ Features * Grunt build for compass and livereload * Basic e-mail configurations for sending emails via Mailgun_ * 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) -* Integration with Sentry_ for error logging (optional) -* Integration with NewRelic_ for performance monitoring (optional) -* Docker support using docker-compose_ for dev and prod +* Docker support using docker-compose_ for development and production * Procfile_ for deploying to Heroku +Optional Integrations +--------------------- + +*These features can be enabled during initial project setup.* + +* Serve static files from Amazon S3 or Whitenoise_ +* Configuration for Celery_ +* Integration with MailHog_ for local email testing +* Integration with Sentry_ for error logging +* Integration with NewRelic_ for performance monitoring + .. _alpha: http://blog.getbootstrap.com/2015/08/19/bootstrap-4-alpha/ .. _Hitch: https://github.com/hitchtest/hitchtest .. _Bootstrap: https://github.com/twbs/bootstrap @@ -52,7 +58,7 @@ Features .. _Mailgun: https://mailgun.com/ .. _Whitenoise: https://whitenoise.readthedocs.org/ .. _Celery: http://www.celeryproject.org/ -.. _Maildump: https://github.com/ThiefMaster/maildump +.. _MailHog: https://github.com/mailhog/MailHog .. _Sentry: https://getsentry.com .. _NewRelic: https://newrelic.com .. _docker-compose: https://www.github.com/docker/compose @@ -107,7 +113,7 @@ It prompts you for questions. Answer them:: year [2015]: use_whitenoise [y]: n use_celery [n]: y - use_maildump [n]: n + use_mailhog [n]: n use_sentry [n]: y use_newrelic [n]: y windows [n]: n diff --git a/cookiecutter.json b/cookiecutter.json index 213c1842..c8b6deee 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -11,7 +11,7 @@ "year": "{{ cookiecutter.now[:4] }}", "use_whitenoise": "y", "use_celery": "n", - "use_maildump": "n", + "use_mailhog": "n", "use_sentry": "n", "use_newrelic": "n", "windows": "n", diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index ae737dc4..349c9120 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -31,9 +31,16 @@ django-allauth sends an email to verify users (and superusers) after signup and .. _configure your email backend: http://docs.djangoproject.com/en/1.8/topics/email/#smtp-backend -In development you can (optionally) use Maildump_ for email testing. Or alternatively simply output emails to the console via: ``EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'`` +In development you can (optionally) use MailHog_ for email testing. MailHog is built with Go so there are no dependencies. To use MailHog:: -.. _Maildump: https://github.com/ThiefMaster/maildump +1. `Download the latest release`_ for your operating system +2. Rename the executable to ``mailhog`` and copy it to the root of your project directory +3. Make sure it is executable (e.g. ``chmod +x mailhog``) + +.. _Mailhog: https://github.com/mailhog/MailHog/ +.. _Download the latest release: https://github.com/mailhog/MailHog/releases + +Alternatively simply output emails to the console via: ``EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'`` In production basic email configuration is setup to send emails with Mailgun_ diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index 2ed91bbb..d879b8ff 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -34,10 +34,10 @@ use_celery [n] Whether to use Celery_. This gives you the ability to use distributed task queues in your project. -use_maildump [n] - Whether to use Maildump_. Maildump is a tool that simulates email receiving - for development purposes. It runs a super simple SMTP server which catches - any message sent to it. Then messages are displayed in a web interface. +use_mailhog [n] + Whether to use MailHog_. MailHog is a tool that simulates email receiving + for development purposes. It runs a simple SMTP server which catches + any message sent to it. Messages are displayed in a web interface which runs at ``http://localhost:8025/`` You need to download the MailHog executable for your operating system, see the 'Developing Locally' docs for instructions. use_sentry [n] Whether to use Sentry_ to log errors from your project. @@ -51,5 +51,5 @@ use_python2 [n] .. _WhiteNoise: https://github.com/evansd/whitenoise .. _Celery: https://github.com/celery/celery -.. _Maildump: https://github.com/ThiefMaster/maildump +.. _MailHog: https://github.com/mailhog/MailHog .. _Sentry: https://github.com/getsentry/sentry diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 74f8947c..0f982660 100644 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -62,7 +62,7 @@ def test_default_configuration(cookies, context): check_paths(paths) -@pytest.fixture(params=['use_maildump', 'use_celery', 'windows']) +@pytest.fixture(params=['use_mailhog', 'use_celery', 'windows']) def feature_context(request, context): context.update({request.param: 'y'}) return context diff --git a/{{cookiecutter.repo_name}}/Gruntfile.js b/{{cookiecutter.repo_name}}/Gruntfile.js index b88b1172..1eaade28 100644 --- a/{{cookiecutter.repo_name}}/Gruntfile.js +++ b/{{cookiecutter.repo_name}}/Gruntfile.js @@ -22,7 +22,6 @@ module.exports = function (grunt) { images: this.app + '/static/images', js: this.app + '/static/js', manageScript: 'manage.py', - {% if cookiecutter.use_maildump=="y" -%}mailserverpid: 'mailserver.pid',{%- endif %} } }; @@ -79,7 +78,7 @@ module.exports = function (grunt) { }, } }, - + //see https://github.com/nDmitry/grunt-postcss postcss: { options: { @@ -113,16 +112,16 @@ 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' + {% if cookiecutter.use_mailhog == "y" -%}runMailHog: { + cmd: './mailhog' },{%- endif %} } }); grunt.registerTask('serve', [ + {% if cookiecutter.use_mailhog == "y" -%} + 'bgShell:runMailHog', + {%- endif %} 'bgShell:runDjango', 'watch' ]); @@ -135,12 +134,5 @@ 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 %} }; diff --git a/{{cookiecutter.repo_name}}/README.rst b/{{cookiecutter.repo_name}}/README.rst index ba7dc216..cbbe3254 100644 --- a/{{cookiecutter.repo_name}}/README.rst +++ b/{{cookiecutter.repo_name}}/README.rst @@ -61,28 +61,25 @@ Please note: For Celerys import magic to work, it is important *where* the celer {% endif %} -{% if cookiecutter.use_maildump == "y" %} +{% if cookiecutter.use_mailhog == "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. +In development, it is often nice to be able to see emails that are being sent from your application. If you choose to use `MailHog`_ when generating the project a local SMTP server with a web interface will be available. -.. _maildump: https://github.com/ThiefMaster/maildump +.. _mailhog: https://github.com/mailhog/MailHog -Make sure you have nodejs installed, and then type the following:: +To start the service, make sure you have nodejs installed, and then type the following:: - $ grunt start-email-server + $ npm install + $ grunt serve -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 +(After the first run you only need to type ``grunt serve``) This will start an email server that listens on ``127.0.0.1:1025`` in addition to starting your Django project and a watch task for live reload. -To stop the email server:: +To view messages that are sent by your application, open your browser and go to ``http://127.0.0.1:8025`` - $ grunt stop-email-server - -The email server listens on 127.0.0.1:1025 +The email server will exit when you exit the Grunt task on the CLI with Ctrl+C. {% endif %} diff --git a/{{cookiecutter.repo_name}}/config/settings/local.py b/{{cookiecutter.repo_name}}/config/settings/local.py index cbe5d58d..25613883 100644 --- a/{{cookiecutter.repo_name}}/config/settings/local.py +++ b/{{cookiecutter.repo_name}}/config/settings/local.py @@ -25,7 +25,7 @@ SECRET_KEY = env("DJANGO_SECRET_KEY", default='CHANGEME!!!') # ------------------------------------------------------------------------------ EMAIL_HOST = 'localhost' EMAIL_PORT = 1025 -{%if cookiecutter.use_maildump == "n" -%} +{%if cookiecutter.use_mailhog == "n" -%} EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.console.EmailBackend') {%- endif %} diff --git a/{{cookiecutter.repo_name}}/requirements/local.txt b/{{cookiecutter.repo_name}}/requirements/local.txt index a9b63d44..04639e4f 100644 --- a/{{cookiecutter.repo_name}}/requirements/local.txt +++ b/{{cookiecutter.repo_name}}/requirements/local.txt @@ -13,15 +13,3 @@ django-debug-toolbar==1.4 # improved REPL ipdb==0.8.1 - -{% if cookiecutter.use_maildump == "y" -%} -# Required by maildump. -{% if cookiecutter.use_python2 == 'n' -%} -# Need to pin dependency to gevent beta to be Python 3-compatible. -gevent==1.1b6 -{% else -%} -gevent==1.0.2 -{% endif -%} -# Enables better email testing -maildump==0.5.1 -{%- endif %} From e4f922763fd5a26f96b0b522e2ae148095f1684a Mon Sep 17 00:00:00 2001 From: Tom Atkins Date: Mon, 16 Nov 2015 19:17:03 +0000 Subject: [PATCH 2/4] Add mailhog binary to gitignore --- {{cookiecutter.repo_name}}/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/{{cookiecutter.repo_name}}/.gitignore b/{{cookiecutter.repo_name}}/.gitignore index 796c7be3..73881c8c 100644 --- a/{{cookiecutter.repo_name}}/.gitignore +++ b/{{cookiecutter.repo_name}}/.gitignore @@ -61,3 +61,6 @@ node_modules/ # Hitch directory tests/.hitch + +# MailHog binary +mailhog From 3316a3b02398ccf4f7430738af0b7b7c471525ae Mon Sep 17 00:00:00 2001 From: Tom Atkins Date: Wed, 18 Nov 2015 11:16:25 +0000 Subject: [PATCH 3/4] Fix merge conflict in README.rst --- README.rst | 6 +++--- cookiecutter.json | 2 +- docs/developing-locally.rst | 11 ++++++++-- docs/project-generation-options.rst | 10 ++++----- tests/test_cookiecutter_generation.py | 2 +- {{cookiecutter.repo_name}}/Gruntfile.js | 20 ++++++------------ {{cookiecutter.repo_name}}/README.rst | 21 ++++++++----------- .../config/settings/local.py | 2 +- .../requirements/local.txt | 12 ----------- 9 files changed, 35 insertions(+), 51 deletions(-) diff --git a/README.rst b/README.rst index f44db093..aa15e89e 100644 --- a/README.rst +++ b/README.rst @@ -42,7 +42,7 @@ Optional Integrations * Serve static files from Amazon S3 or Whitenoise_ * Configuration for Celery_ -* Integration with Maildump_ for local email testing +* Integration with MailHog_ for local email testing * Integration with Sentry_ for error logging * Integration with NewRelic_ for performance monitoring * Integration with Opbeat_ for performance monitoring @@ -59,7 +59,7 @@ Optional Integrations .. _Mailgun: https://mailgun.com/ .. _Whitenoise: https://whitenoise.readthedocs.org/ .. _Celery: http://www.celeryproject.org/ -.. _Maildump: https://github.com/ThiefMaster/maildump +.. _MailHog: https://github.com/mailhog/MailHog .. _Sentry: https://getsentry.com .. _NewRelic: https://newrelic.com .. _docker-compose: https://www.github.com/docker/compose @@ -115,7 +115,7 @@ It prompts you for questions. Answer them:: year [2015]: use_whitenoise [y]: n use_celery [n]: y - use_maildump [n]: n + use_mailhog [n]: n use_sentry [n]: y use_newrelic [n]: y use_obpeat [n]: y diff --git a/cookiecutter.json b/cookiecutter.json index 4367b8b1..162d6b38 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -11,7 +11,7 @@ "year": "{{ cookiecutter.now[:4] }}", "use_whitenoise": "y", "use_celery": "n", - "use_maildump": "n", + "use_mailhog": "n", "use_sentry": "n", "use_newrelic": "n", "use_opbeat": "n", diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index ae737dc4..349c9120 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -31,9 +31,16 @@ django-allauth sends an email to verify users (and superusers) after signup and .. _configure your email backend: http://docs.djangoproject.com/en/1.8/topics/email/#smtp-backend -In development you can (optionally) use Maildump_ for email testing. Or alternatively simply output emails to the console via: ``EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'`` +In development you can (optionally) use MailHog_ for email testing. MailHog is built with Go so there are no dependencies. To use MailHog:: -.. _Maildump: https://github.com/ThiefMaster/maildump +1. `Download the latest release`_ for your operating system +2. Rename the executable to ``mailhog`` and copy it to the root of your project directory +3. Make sure it is executable (e.g. ``chmod +x mailhog``) + +.. _Mailhog: https://github.com/mailhog/MailHog/ +.. _Download the latest release: https://github.com/mailhog/MailHog/releases + +Alternatively simply output emails to the console via: ``EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'`` In production basic email configuration is setup to send emails with Mailgun_ diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index 2ed91bbb..d879b8ff 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -34,10 +34,10 @@ use_celery [n] Whether to use Celery_. This gives you the ability to use distributed task queues in your project. -use_maildump [n] - Whether to use Maildump_. Maildump is a tool that simulates email receiving - for development purposes. It runs a super simple SMTP server which catches - any message sent to it. Then messages are displayed in a web interface. +use_mailhog [n] + Whether to use MailHog_. MailHog is a tool that simulates email receiving + for development purposes. It runs a simple SMTP server which catches + any message sent to it. Messages are displayed in a web interface which runs at ``http://localhost:8025/`` You need to download the MailHog executable for your operating system, see the 'Developing Locally' docs for instructions. use_sentry [n] Whether to use Sentry_ to log errors from your project. @@ -51,5 +51,5 @@ use_python2 [n] .. _WhiteNoise: https://github.com/evansd/whitenoise .. _Celery: https://github.com/celery/celery -.. _Maildump: https://github.com/ThiefMaster/maildump +.. _MailHog: https://github.com/mailhog/MailHog .. _Sentry: https://github.com/getsentry/sentry diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 74f8947c..0f982660 100644 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -62,7 +62,7 @@ def test_default_configuration(cookies, context): check_paths(paths) -@pytest.fixture(params=['use_maildump', 'use_celery', 'windows']) +@pytest.fixture(params=['use_mailhog', 'use_celery', 'windows']) def feature_context(request, context): context.update({request.param: 'y'}) return context diff --git a/{{cookiecutter.repo_name}}/Gruntfile.js b/{{cookiecutter.repo_name}}/Gruntfile.js index b88b1172..1eaade28 100644 --- a/{{cookiecutter.repo_name}}/Gruntfile.js +++ b/{{cookiecutter.repo_name}}/Gruntfile.js @@ -22,7 +22,6 @@ module.exports = function (grunt) { images: this.app + '/static/images', js: this.app + '/static/js', manageScript: 'manage.py', - {% if cookiecutter.use_maildump=="y" -%}mailserverpid: 'mailserver.pid',{%- endif %} } }; @@ -79,7 +78,7 @@ module.exports = function (grunt) { }, } }, - + //see https://github.com/nDmitry/grunt-postcss postcss: { options: { @@ -113,16 +112,16 @@ 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' + {% if cookiecutter.use_mailhog == "y" -%}runMailHog: { + cmd: './mailhog' },{%- endif %} } }); grunt.registerTask('serve', [ + {% if cookiecutter.use_mailhog == "y" -%} + 'bgShell:runMailHog', + {%- endif %} 'bgShell:runDjango', 'watch' ]); @@ -135,12 +134,5 @@ 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 %} }; diff --git a/{{cookiecutter.repo_name}}/README.rst b/{{cookiecutter.repo_name}}/README.rst index ba7dc216..cbbe3254 100644 --- a/{{cookiecutter.repo_name}}/README.rst +++ b/{{cookiecutter.repo_name}}/README.rst @@ -61,28 +61,25 @@ Please note: For Celerys import magic to work, it is important *where* the celer {% endif %} -{% if cookiecutter.use_maildump == "y" %} +{% if cookiecutter.use_mailhog == "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. +In development, it is often nice to be able to see emails that are being sent from your application. If you choose to use `MailHog`_ when generating the project a local SMTP server with a web interface will be available. -.. _maildump: https://github.com/ThiefMaster/maildump +.. _mailhog: https://github.com/mailhog/MailHog -Make sure you have nodejs installed, and then type the following:: +To start the service, make sure you have nodejs installed, and then type the following:: - $ grunt start-email-server + $ npm install + $ grunt serve -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 +(After the first run you only need to type ``grunt serve``) This will start an email server that listens on ``127.0.0.1:1025`` in addition to starting your Django project and a watch task for live reload. -To stop the email server:: +To view messages that are sent by your application, open your browser and go to ``http://127.0.0.1:8025`` - $ grunt stop-email-server - -The email server listens on 127.0.0.1:1025 +The email server will exit when you exit the Grunt task on the CLI with Ctrl+C. {% endif %} diff --git a/{{cookiecutter.repo_name}}/config/settings/local.py b/{{cookiecutter.repo_name}}/config/settings/local.py index cbe5d58d..25613883 100644 --- a/{{cookiecutter.repo_name}}/config/settings/local.py +++ b/{{cookiecutter.repo_name}}/config/settings/local.py @@ -25,7 +25,7 @@ SECRET_KEY = env("DJANGO_SECRET_KEY", default='CHANGEME!!!') # ------------------------------------------------------------------------------ EMAIL_HOST = 'localhost' EMAIL_PORT = 1025 -{%if cookiecutter.use_maildump == "n" -%} +{%if cookiecutter.use_mailhog == "n" -%} EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.console.EmailBackend') {%- endif %} diff --git a/{{cookiecutter.repo_name}}/requirements/local.txt b/{{cookiecutter.repo_name}}/requirements/local.txt index a9b63d44..04639e4f 100644 --- a/{{cookiecutter.repo_name}}/requirements/local.txt +++ b/{{cookiecutter.repo_name}}/requirements/local.txt @@ -13,15 +13,3 @@ django-debug-toolbar==1.4 # improved REPL ipdb==0.8.1 - -{% if cookiecutter.use_maildump == "y" -%} -# Required by maildump. -{% if cookiecutter.use_python2 == 'n' -%} -# Need to pin dependency to gevent beta to be Python 3-compatible. -gevent==1.1b6 -{% else -%} -gevent==1.0.2 -{% endif -%} -# Enables better email testing -maildump==0.5.1 -{%- endif %} From c653801d5ae72005b9307bf41277ded4e48ca016 Mon Sep 17 00:00:00 2001 From: Tom Atkins Date: Mon, 16 Nov 2015 19:17:03 +0000 Subject: [PATCH 4/4] Add mailhog binary to gitignore --- {{cookiecutter.repo_name}}/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/{{cookiecutter.repo_name}}/.gitignore b/{{cookiecutter.repo_name}}/.gitignore index 0757b98b..4b288b5b 100644 --- a/{{cookiecutter.repo_name}}/.gitignore +++ b/{{cookiecutter.repo_name}}/.gitignore @@ -60,3 +60,6 @@ node_modules/ # Hitch directory tests/.hitch + +# MailHog binary +mailhog