From 73137e17644ef2bb31f72f6166824c8bbcfa6396 Mon Sep 17 00:00:00 2001 From: Vageeshan Mankala <43883923+vagi8@users.noreply.github.com> Date: Wed, 6 Sep 2023 12:41:01 -0700 Subject: [PATCH] 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 --- README.md | 4 +-- cookiecutter.json | 2 +- docs/developing-locally-docker.rst | 8 +++--- docs/developing-locally.rst | 20 +++++++------- docs/project-generation-options.rst | 6 ++--- tests/test_cookiecutter_generation.py | 4 +-- {{cookiecutter.project_slug}}/.gitignore | 4 +-- {{cookiecutter.project_slug}}/README.md | 26 +++++++++---------- .../config/settings/local.py | 6 ++--- {{cookiecutter.project_slug}}/local.yml | 20 +++++++------- 10 files changed, 48 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 7f2c358e..c9d3d348 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cookiecutter.json b/cookiecutter.json index f66e281f..e343617d 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -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", diff --git a/docs/developing-locally-docker.rst b/docs/developing-locally-docker.rst index 6af4fe7c..a8f945ad 100644 --- a/docs/developing-locally-docker.rst +++ b/docs/developing-locally-docker.rst @@ -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 ``_local_mailhog`` container is up and running; +#. make sure ``_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`: diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index 88c8b320..92379f4f 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -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 ``_ 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'``. diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index bd368ae8..967b4242 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -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 diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 87e52ef0..31d006be 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -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"}, diff --git a/{{cookiecutter.project_slug}}/.gitignore b/{{cookiecutter.project_slug}}/.gitignore index 541f4084..0bb32218 100644 --- a/{{cookiecutter.project_slug}}/.gitignore +++ b/{{cookiecutter.project_slug}}/.gitignore @@ -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/ diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index 56853f8f..ccf245a2 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -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 to see how it goes. +5. Check out to see how it goes. Now you have your own mail server running locally, ready to receive whatever you send it. diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py index adab6087..0304d6cd 100644 --- a/{{cookiecutter.project_slug}}/config/settings/local.py +++ b/{{cookiecutter.project_slug}}/config/settings/local.py @@ -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 diff --git a/{{cookiecutter.project_slug}}/local.yml b/{{cookiecutter.project_slug}}/local.yml index e55e18d3..692d8749 100644 --- a/{{cookiecutter.project_slug}}/local.yml +++ b/{{cookiecutter.project_slug}}/local.yml @@ -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