mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-21 17:16:51 +03:00
Replace Mailhog with Mailpit (#4551)
* modifying cookiecutter.json with new config * updated docker image and its local settings * replacing use_mailhog conditions * replacing use_mailhog condition in docs * Updating docs with mailpit
This commit is contained in:
parent
b2c2eedb6d
commit
73137e1764
|
@ -45,7 +45,7 @@ _These features can be enabled during initial project setup._
|
|||
|
||||
- Serve static files from Amazon S3, Google Cloud Storage, Azure Storage or [Whitenoise](https://whitenoise.readthedocs.io/)
|
||||
- Configuration for [Celery](https://docs.celeryq.dev) and [Flower](https://github.com/mher/flower) (the latter in Docker setup only)
|
||||
- Integration with [MailHog](https://github.com/mailhog/MailHog) for local email testing
|
||||
- Integration with [Mailpit](https://github.com/axllent/mailpit/) for local email testing
|
||||
- Integration with [Sentry](https://sentry.io/welcome/) for error logging
|
||||
|
||||
## Constraints
|
||||
|
@ -165,7 +165,7 @@ Answer the prompts with your own desired [options](http://cookiecutter-django.re
|
|||
4 - Webpack
|
||||
Choose from 1, 2, 3, 4 [1]: 1
|
||||
use_celery [n]: y
|
||||
use_mailhog [n]: n
|
||||
use_mailpit [n]: n
|
||||
use_sentry [n]: y
|
||||
use_whitenoise [n]: n
|
||||
use_heroku [n]: y
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
"use_drf": "n",
|
||||
"frontend_pipeline": ["None", "Django Compressor", "Gulp", "Webpack"],
|
||||
"use_celery": "n",
|
||||
"use_mailhog": "n",
|
||||
"use_mailpit": "n",
|
||||
"use_sentry": "n",
|
||||
"use_whitenoise": "n",
|
||||
"use_heroku": "n",
|
||||
|
|
|
@ -191,16 +191,16 @@ The ``container_name`` from the yml file can be used to check on containers with
|
|||
|
||||
Notice that the ``container_name`` is generated dynamically using your project slug as a prefix
|
||||
|
||||
Mailhog
|
||||
Mailpit
|
||||
~~~~~~~
|
||||
|
||||
When developing locally you can go with MailHog_ for email testing provided ``use_mailhog`` was set to ``y`` on setup. To proceed,
|
||||
When developing locally you can go with Mailpit_ for email testing provided ``use_mailpit`` was set to ``y`` on setup. To proceed,
|
||||
|
||||
#. make sure ``<project_slug>_local_mailhog`` container is up and running;
|
||||
#. make sure ``<project_slug>_local_mailpit`` container is up and running;
|
||||
|
||||
#. open up ``http://127.0.0.1:8025``.
|
||||
|
||||
.. _Mailhog: https://github.com/mailhog/MailHog/
|
||||
.. _Mailpit: https://github.com/axllent/mailpit/
|
||||
|
||||
.. _`CeleryTasks`:
|
||||
|
||||
|
|
|
@ -99,39 +99,37 @@ First things first.
|
|||
Setup Email Backend
|
||||
-------------------
|
||||
|
||||
MailHog
|
||||
Mailpit
|
||||
~~~~~~~
|
||||
|
||||
.. note:: In order for the project to support MailHog_ it must have been bootstrapped with ``use_mailhog`` set to ``y``.
|
||||
.. note:: In order for the project to support Mailpit_ it must have been bootstrapped with ``use_mailpit`` set to ``y``.
|
||||
|
||||
MailHog is used to receive emails during development, it is written in Go and has no external dependencies.
|
||||
Mailpit is used to receive emails during development, it is written in Go and has no external dependencies.
|
||||
|
||||
For instance, one of the packages we depend upon, ``django-allauth`` sends verification emails to new users signing up as well as to the existing ones who have not yet verified themselves.
|
||||
|
||||
#. `Download the latest MailHog release`_ for your OS.
|
||||
#. `Download the latest Mailpit release`_ for your OS.
|
||||
|
||||
#. Rename the build to ``MailHog``.
|
||||
|
||||
#. Copy the file to the project root.
|
||||
#. Copy the binary file to the project root.
|
||||
|
||||
#. Make it executable: ::
|
||||
|
||||
$ chmod +x MailHog
|
||||
$ chmod +x mailpit
|
||||
|
||||
#. Spin up another terminal window and start it there: ::
|
||||
|
||||
./MailHog
|
||||
./mailpit
|
||||
|
||||
#. Check out `<http://127.0.0.1:8025/>`_ to see how it goes.
|
||||
|
||||
Now you have your own mail server running locally, ready to receive whatever you send it.
|
||||
|
||||
.. _`Download the latest MailHog release`: https://github.com/mailhog/MailHog
|
||||
.. _`Download the latest Mailpit release`: https://github.com/axllent/mailpit
|
||||
|
||||
Console
|
||||
~~~~~~~
|
||||
|
||||
.. note:: If you have generated your project with ``use_mailhog`` set to ``n`` this will be a default setup.
|
||||
.. note:: If you have generated your project with ``use_mailpit`` set to ``n`` this will be a default setup.
|
||||
|
||||
Alternatively, deliver emails over console via ``EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'``.
|
||||
|
||||
|
|
|
@ -115,8 +115,8 @@ Both Gulp and Webpack support Bootstrap recompilation with real-time variables a
|
|||
use_celery:
|
||||
Indicates whether the project should be configured to use Celery_.
|
||||
|
||||
use_mailhog:
|
||||
Indicates whether the project should be configured to use MailHog_.
|
||||
use_mailpit:
|
||||
Indicates whether the project should be configured to use Mailpit_.
|
||||
|
||||
use_sentry:
|
||||
Indicates whether the project should be configured to use Sentry_.
|
||||
|
@ -185,7 +185,7 @@ debug:
|
|||
|
||||
.. _Celery: https://github.com/celery/celery
|
||||
|
||||
.. _MailHog: https://github.com/mailhog/MailHog
|
||||
.. _Mailpit: https://github.com/axllent/mailpit
|
||||
|
||||
.. _Sentry: https://github.com/getsentry/sentry
|
||||
|
||||
|
|
|
@ -115,8 +115,8 @@ SUPPORTED_COMBINATIONS = [
|
|||
{"frontend_pipeline": "Webpack"},
|
||||
{"use_celery": "y"},
|
||||
{"use_celery": "n"},
|
||||
{"use_mailhog": "y"},
|
||||
{"use_mailhog": "n"},
|
||||
{"use_mailpit": "y"},
|
||||
{"use_mailpit": "n"},
|
||||
{"use_sentry": "y"},
|
||||
{"use_sentry": "n"},
|
||||
{"use_whitenoise": "y"},
|
||||
|
|
4
{{cookiecutter.project_slug}}/.gitignore
vendored
4
{{cookiecutter.project_slug}}/.gitignore
vendored
|
@ -329,8 +329,8 @@ tags
|
|||
dump.rdb
|
||||
|
||||
### Project template
|
||||
{%- if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' %}
|
||||
MailHog
|
||||
{%- if cookiecutter.use_mailpit == 'y' and cookiecutter.use_docker == 'n' %}
|
||||
mailpit
|
||||
{%- endif %}
|
||||
{{ cookiecutter.project_slug }}/media/
|
||||
|
||||
|
|
|
@ -78,37 +78,35 @@ celery -A config.celery_app worker -B -l info
|
|||
```
|
||||
|
||||
{%- endif %}
|
||||
{%- if cookiecutter.use_mailhog == "y" %}
|
||||
{%- if cookiecutter.use_mailpit == "y" %}
|
||||
|
||||
### Email Server
|
||||
|
||||
{%- if cookiecutter.use_docker == "y" %}
|
||||
|
||||
In development, it is often nice to be able to see emails that are being sent from your application. For that reason local SMTP server [MailHog](https://github.com/mailhog/MailHog) with a web interface is available as docker container.
|
||||
In development, it is often nice to be able to see emails that are being sent from your application. For that reason local SMTP server [Mailpit](https://github.com/axllent/mailpit) with a web interface is available as docker container.
|
||||
|
||||
Container mailhog will start automatically when you will run all docker containers.
|
||||
Container mailpit will start automatically when you will run all docker containers.
|
||||
Please check [cookiecutter-django Docker documentation](http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html) for more details how to start all containers.
|
||||
|
||||
With MailHog running, to view messages that are sent by your application, open your browser and go to `http://127.0.0.1:8025`
|
||||
With Mailpit running, to view messages that are sent by your application, open your browser and go to `http://127.0.0.1:8025`
|
||||
{%- else %}
|
||||
|
||||
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](https://github.com/mailhog/MailHog) when generating the project a local SMTP server with a web interface will be available.
|
||||
In development, it is often nice to be able to see emails that are being sent from your application. If you choose to use [Mailpit](https://github.com/axllent/mailpit) when generating the project a local SMTP server with a web interface will be available.
|
||||
|
||||
1. [Download the latest MailHog release](https://github.com/mailhog/MailHog/releases) for your OS.
|
||||
1. [Download the latest Mailpit release](https://github.com/axllent/mailpit/releases) for your OS.
|
||||
|
||||
2. Rename the build to `MailHog`.
|
||||
2. Copy the binary file to the project root.
|
||||
|
||||
3. Copy the file to the project root.
|
||||
3. Make it executable:
|
||||
|
||||
4. Make it executable:
|
||||
$ chmod +x mailpit
|
||||
|
||||
$ chmod +x MailHog
|
||||
4. Spin up another terminal window and start it there:
|
||||
|
||||
5. Spin up another terminal window and start it there:
|
||||
./mailpit
|
||||
|
||||
./MailHog
|
||||
|
||||
6. Check out <http://127.0.0.1:8025/> to see how it goes.
|
||||
5. Check out <http://127.0.0.1:8025/> to see how it goes.
|
||||
|
||||
Now you have your own mail server running locally, ready to receive whatever you send it.
|
||||
|
||||
|
|
|
@ -25,12 +25,12 @@ CACHES = {
|
|||
|
||||
# EMAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' -%}
|
||||
{% if cookiecutter.use_mailpit == 'y' and cookiecutter.use_docker == 'y' -%}
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
||||
EMAIL_HOST = env("EMAIL_HOST", default="mailhog")
|
||||
EMAIL_HOST = env("EMAIL_HOST", default="mailpit")
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
|
||||
EMAIL_PORT = 1025
|
||||
{%- elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' -%}
|
||||
{%- elif cookiecutter.use_mailpit == 'y' and cookiecutter.use_docker == 'n' -%}
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
||||
EMAIL_HOST = "localhost"
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
|
||||
|
|
|
@ -16,8 +16,8 @@ services:
|
|||
{%- if cookiecutter.use_celery == 'y' %}
|
||||
- redis
|
||||
{%- endif %}
|
||||
{%- if cookiecutter.use_mailhog == 'y' %}
|
||||
- mailhog
|
||||
{%- if cookiecutter.use_mailpit == 'y' %}
|
||||
- mailpit
|
||||
{%- endif %}
|
||||
volumes:
|
||||
- .:/app:z
|
||||
|
@ -55,11 +55,11 @@ services:
|
|||
ports:
|
||||
- '9000:9000'
|
||||
command: /start-docs
|
||||
{%- if cookiecutter.use_mailhog == 'y' %}
|
||||
{%- if cookiecutter.use_mailpit == 'y' %}
|
||||
|
||||
mailhog:
|
||||
image: mailhog/mailhog:v1.0.0
|
||||
container_name: {{ cookiecutter.project_slug }}_local_mailhog
|
||||
mailpit:
|
||||
image: axllent/mailpit:v1.8
|
||||
container_name: {{ cookiecutter.project_slug }}_local_mailpit
|
||||
ports:
|
||||
- "8025:8025"
|
||||
|
||||
|
@ -77,8 +77,8 @@ services:
|
|||
depends_on:
|
||||
- redis
|
||||
- postgres
|
||||
{%- if cookiecutter.use_mailhog == 'y' %}
|
||||
- mailhog
|
||||
{%- if cookiecutter.use_mailpit == 'y' %}
|
||||
- mailpit
|
||||
{%- endif %}
|
||||
ports: []
|
||||
command: /start-celeryworker
|
||||
|
@ -90,8 +90,8 @@ services:
|
|||
depends_on:
|
||||
- redis
|
||||
- postgres
|
||||
{%- if cookiecutter.use_mailhog == 'y' %}
|
||||
- mailhog
|
||||
{%- if cookiecutter.use_mailpit == 'y' %}
|
||||
- mailpit
|
||||
{%- endif %}
|
||||
ports: []
|
||||
command: /start-celerybeat
|
||||
|
|
Loading…
Reference in New Issue
Block a user