Skip to content

Commit

Permalink
replaces mailhog with mailpit
Browse files Browse the repository at this point in the history
  • Loading branch information
shelane committed Apr 3, 2024
1 parent 9c5aebb commit d8471cf
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 121 deletions.
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ DISCLAMER: since it is a community driven project it is only smoke-tested and co

# Addons list

| Name | Description | Requirements |
|--- |--- |--- |
| **[example](example)** | A working documentation on what is Docksal addon and how it works | |
| [adminer](adminer) | [Adminer](https://www.adminer.org/) database management tool | MySQL |
| [andock](andock) | [Andock](https://andock.readthedocs.io/en/latest/) makes it dead simple to get Docksal environments up on your server. | Docksal |
| [artisan](artisan) | Runs [Laravel's Artisan](https://laravel.com/docs/artisan) command in `cli`. **Requires** artisan pre-installed inside `cli`. | Laravel, Artisan |
| [blt](blt) | Acquia BLT tool launcher (requires [BLT installation](https://blog.docksal.io/docksal-and-acquia-blt-1552540a3b9f)) | Drupal |
| [codeclimate](codeclimate) | [CodeClimate](https://codeclimate.com/) code quality tool | |
| [dbeaver](dbeaver) | Launches [DBeaver](https://dbeaver.io/) with the connection information for current project. | macOS, Linux |
| [mailhog](mailhog) | [Mailhog](https://github.com/mailhog/MailHog) e-mail capture service for current project | |
| [meilisearch](meilisearch) | [Meilisearch](https://www.meilisearch.com/) search for local development | |
| [mkcert](mkcert) | [mkcert](https://github.com/FiloSottile/mkcert) addon for Docksal | |
| [phpcs](phpcs) | PHP Code Sniffer and Code Beautifier | |
| [phpunit](phpunit) | Creates a phpunit.xml file and runs PHPUnit tests | Drupal |
| [pma](pma) | [PhpMyAdmin](https://www.phpmyadmin.net/) database management tool | MySQL |
| [pull](pull) | Pull assets from hosting environment to local | Drupal |
| [rabbitmq](rabbitmq) | [RabbitMQ](https://www.rabbitmq.com/) Message Broker | RabbitMQ |
| [redis](redis) | Add [Redis](https://redis.io/) to current project | |
| [sequelace](sequelace) | Launches [SequelAce](https://github.com/Sequel-Ace/Sequel-Ace) with the connection information for current project. | macOS |
| [sequelpro](sequelpro) | Launches [SequelPro](https://www.sequelpro.com) with the connection information for current project. | macOS |
| [simpletest](simpletest) | Runs SimpleTest tests in Drupal 7 and 8 | Drupal |
| [sitediff](sitediff) | Runs Sitediff tests in your Docksal project | |
| [soketi](soketi) | [Socketi](https://docs.soketi.app/) Soketi is your simple, fast, and resilient open-source WebSockets server | |
| [solr](solr) | [Apache Solr](http://lucene.apache.org/solr/) search service for current project | |
| [tableplus](tableplus) | Launches [TablePlus](https://www.tableplus.com) with the connection information for current project. | macOS |
| [uli](uli) | Generate one time login url for current site | Drupal |
| [wkhtmltopdf](wkhtmltopdf) | Installs wkhtmltopdf 0.12.5 with QT compiled in. | |
| [xdebug](xdebug) | Turns [xdebug](https://docs.docksal.io/tools/xdebug/) on or off and restarts docksal | |
| Name | Description | Requirements |
|----------------------------|--- |--- |
| **[example](example)** | A working documentation on what is Docksal addon and how it works | |
| [adminer](adminer) | [Adminer](https://www.adminer.org/) database management tool | MySQL |
| [andock](andock) | [Andock](https://andock.readthedocs.io/en/latest/) makes it dead simple to get Docksal environments up on your server. | Docksal |
| [artisan](artisan) | Runs [Laravel's Artisan](https://laravel.com/docs/artisan) command in `cli`. **Requires** artisan pre-installed inside `cli`. | Laravel, Artisan |
| [blt](blt) | Acquia BLT tool launcher (requires [BLT installation](https://blog.docksal.io/docksal-and-acquia-blt-1552540a3b9f)) | Drupal |
| [codeclimate](codeclimate) | [CodeClimate](https://codeclimate.com/) code quality tool | |
| [dbeaver](dbeaver) | Launches [DBeaver](https://dbeaver.io/) with the connection information for current project. | macOS, Linux |
| [mailpit](mailpit) | [Mailhog](https://github.com/axllent/mailpit) email capture service for current project | |
| [meilisearch](meilisearch) | [Meilisearch](https://www.meilisearch.com/) search for local development | |
| [mkcert](mkcert) | [mkcert](https://github.com/FiloSottile/mkcert) addon for Docksal | |
| [phpcs](phpcs) | PHP Code Sniffer and Code Beautifier | |
| [phpunit](phpunit) | Creates a phpunit.xml file and runs PHPUnit tests | Drupal |
| [pma](pma) | [PhpMyAdmin](https://www.phpmyadmin.net/) database management tool | MySQL |
| [pull](pull) | Pull assets from hosting environment to local | Drupal |
| [rabbitmq](rabbitmq) | [RabbitMQ](https://www.rabbitmq.com/) Message Broker | RabbitMQ |
| [redis](redis) | Add [Redis](https://redis.io/) to current project | |
| [sequelace](sequelace) | Launches [SequelAce](https://github.com/Sequel-Ace/Sequel-Ace) with the connection information for current project. | macOS |
| [sequelpro](sequelpro) | Launches [SequelPro](https://www.sequelpro.com) with the connection information for current project. | macOS |
| [simpletest](simpletest) | Runs SimpleTest tests in Drupal 7 and 8 | Drupal |
| [sitediff](sitediff) | Runs Sitediff tests in your Docksal project | |
| [soketi](soketi) | [Socketi](https://docs.soketi.app/) Soketi is your simple, fast, and resilient open-source WebSockets server | |
| [solr](solr) | [Apache Solr](http://lucene.apache.org/solr/) search service for current project | |
| [tableplus](tableplus) | Launches [TablePlus](https://www.tableplus.com) with the connection information for current project. | macOS |
| [uli](uli) | Generate one time login url for current site | Drupal |
| [wkhtmltopdf](wkhtmltopdf) | Installs wkhtmltopdf 0.12.5 with QT compiled in. | |
| [xdebug](xdebug) | Turns [xdebug](https://docs.docksal.io/tools/xdebug/) on or off and restarts docksal | |
12 changes: 0 additions & 12 deletions mailhog/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions mailhog/conf/mailhog.ini

This file was deleted.

4 changes: 0 additions & 4 deletions mailhog/conf/mailhog.yml

This file was deleted.

10 changes: 0 additions & 10 deletions mailhog/mailhog.filelist

This file was deleted.

6 changes: 0 additions & 6 deletions mailhog/mailhog.post-install

This file was deleted.

12 changes: 12 additions & 0 deletions mailpit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# mailpit

Easily install Mailpit email catcher for your Docksal project

```bash
fin addon install mailpit
```

## Usage once installed

- `fin mailpit disable` to disable
- `fin mailpit enable` to re-enable
5 changes: 5 additions & 0 deletions mailpit/conf/mailpit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Mailpit
mail:
extends:
file: ${HOME}/.docksal/stacks/services.yml
service: mail
74 changes: 21 additions & 53 deletions mailhog/mailhog → mailpit/mailpit
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env bash

## Enable/disable mailhog for current project
## Enable/disable mailpit for current project
##
## Sub-commands:
## enable Enable mailhog
## disable Disable mailhog
## enable Enable mailpit
## disable Disable mailpit

red='\033[0;31m'
green='\033[0;32m'
Expand All @@ -22,9 +22,7 @@ DOCKSAL_YML=".docksal/docksal.yml"
DOCKSAL_YML_NEW=".docksal/docksal.yml.new"
DOCKSAL_ENV=".docksal/docksal.env"
DOCKSAL_STACKS="$HOME/.docksal/stacks"
PHP_INI=".docksal/etc/php/php.ini"
MAILHOG_INI="$ADDON_ROOT/conf/mailhog.ini"
MAILHOG_YML="$ADDON_ROOT/conf/mailhog.yml"
MAILPIT_YML="$ADDON_ROOT/conf/mailpit.yml"

#----------------------------------- YML & config functions ------------------------------------------

Expand Down Expand Up @@ -92,74 +90,44 @@ yml_remove_service ()
fin exec "$CODE_TO_EXEC"
}

#-------------------------------------- MailHog functions ---------------------------------------------
#-------------------------------------- mailpit functions ---------------------------------------------

# Set/remove proper setting into php.ini
# $1 - enable/disable
mailhog_php_support ()
{
case "$1" in
enable)
# Create file if not exists
if [[ ! -f "$PHP_INI" ]]; then
mkdir -p $(dirname "$PHP_INI")
echo -e "[php]\n" > "$PHP_INI"
fi
# Append sendmail setting
cat "$MAILHOG_INI" >> "$PHP_INI"
# Remove double empty lines for clarity
cat -s "$PHP_INI" | tee "$PHP_INI" >/dev/null
;;
disable)
[[ ! -f "$PHP_INI" ]] && return
php_ini_contents=$(cat "$PHP_INI")
mailhog_ini_contents=$(cat "$MAILHOG_INI")
# Remove all lines that present in mailhog.ini from php.ini
php_ini_contents=${php_ini_contents/$mailhog_ini_contents/}
echo -e "$php_ini_contents" > "$PHP_INI"
;;
esac
}

# Enable container and settings
mailhog_enable ()
MAILPIT_enable ()
{
# Check that mailhog is not already enabled
if (in_config "image: mailhog\/mailhog"); then
echo " Mailhog support is already enabled." && exit
# Check that mailpit is not already enabled
if (in_config "image: axllent\/mailpit"); then
echo " Mailpit support is already enabled." && exit
fi

echo " Enabling mailhog..."
echo " Enabling mailpit..."
yml_prepare
# Add mailhog service to docksal.yml
yml_add_service "$MAILHOG_YML"
# Add php.ini setting
mailhog_php_support enable
# Add mailpit service to docksal.yml
yml_add_service "$MAILPIT_YML"
# Apply stack changes.
fin stop cli
fin up
}

# Disable container and settings
mailhog_disable ()
MAILPIT_disable ()
{
echo " Running checks..."
# Make sure cli container is running
if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then
echo " ERROR: Start the project with fin start first" && exit 1
fi

# Make sure mailhog is installed
if ! in_config "image: mailhog\/mailhog"; then
echo " Mailhog support is not enabled at the moment." && exit
# Make sure mailpit is installed
if ! in_config "image: axllent\/mailpit"; then
echo " Mailpit support is not enabled at the moment." && exit
fi

echo " Preparing to remove mailhog service..."
echo " Preparing to remove mailpit service..."
yml_install_tools
# Remove mailhog service from docksal.yml
# Remove mailpit service from docksal.yml
yml_remove_service "mail"
# Remove php.ini setting
mailhog_php_support disable
# Apply stack changes
COMPOSE_FILE="" fin stop cli
fin up
Expand All @@ -171,13 +139,13 @@ cd "$PROJECT_ROOT"

case "$1" in
enable)
mailhog_enable
MAILPIT_enable
;;
disable)
mailhog_disable
MAILPIT_disable
;;
*)
echo "Usage: fin mailhog <enable|disable>"
echo "Usage: fin mailpit <enable|disable>"
exit 1
;;
esac
7 changes: 7 additions & 0 deletions mailpit/mailpit.filelist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hooks
mailpit.pre-install
mailpit.post-install
mailpit.pre-uninstall

# Container config
conf/mailpit.yml
6 changes: 6 additions & 0 deletions mailpit/mailpit.post-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

fin mailpit enable

echo -e "${green}Mailpit UI:${NC} http://mail.<project_name>.docksal"
echo -e "${green}More documentation:${NC} http://docs.docksal.io/en/master/tools/mailpit/"
10 changes: 5 additions & 5 deletions mailhog/mailhog.pre-install → mailpit/mailpit.pre-install
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi

# Check Docksal running
if [[ "$ADDON_GLOBAL" == "true" ]]; then
echo -e "[PRE-INSTALL] ERROR: Mailhog addon should not be installed globally"
echo -e "[PRE-INSTALL] ERROR: Mailpit addon should not be installed globally"
exit 1
fi

Expand All @@ -26,13 +26,13 @@ if [[ $? != 0 ]]; then
exit 1
fi

# Check there is no mailhog already
if (echo "$fin_config" | grep "image: mailhog\/mailhog"); then
echo "[PRE-INSTALL] ERROR: Mailhog seems to be already enabled for this project"
# Check there is no mailpit already
if (echo "$fin_config" | grep "image: axllent\/mailpit"); then
echo "[PRE-INSTALL] ERROR: Mailpit seems to be already enabled for this project"
exit 1
fi

# Check there is no mailhog already
# Check there is no mailpit already
if (echo "$fin_config" | grep " mail:"); then
echo "[PRE-INSTALL] ERROR: Container named 'mail' already exists. Remove it to continue."
exit 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

fin mailhog disable
fin mailpit disable

0 comments on commit d8471cf

Please sign in to comment.