From f9ec8f6317b348d3a14acfbf84ef8bce0c8762a3 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Mon, 21 Feb 2022 15:37:35 +0100
Subject: [PATCH] composer/plugin/docker4drupal#44 Enable preconfigured Mailhog
 release mail feature

---
 src/Handler.php                   | 10 ++++++++++
 templates/docker-compose.yml.twig |  5 +++++
 templates/mhout.json.twig         | 10 ++++++++++
 3 files changed, 25 insertions(+)
 create mode 100644 templates/mhout.json.twig

diff --git a/src/Handler.php b/src/Handler.php
index 35a2ad9..1b5d4ec 100644
--- a/src/Handler.php
+++ b/src/Handler.php
@@ -90,6 +90,13 @@ class Handler extends BaseHandler {
         'type' => 'apache',
         'overwriteconfig' => FALSE,
       ],
+      'mailhog' => [
+        'host' => $this->env->receiveGlobal('MAILHOG_HOST', 'smtp.freesmtpservers.com'),
+        'port' => $this->env->receiveGlobal('MAILHOG_PORT', '25'),
+        'username' => $this->env->receiveGlobal('MAILHOG_USERNAME', ''),
+        'password' => $this->env->receiveGlobal('MAILHOG_PASSWORD', ''),
+        'mechanism' => $this->env->receiveGlobal('MAILHOG_MECHANISM', 'NONE'),
+      ],
       'varnish' => [
         'enable' => 0,
       ],
@@ -373,6 +380,9 @@ class Handler extends BaseHandler {
         'dest' => $projectRoot . '/apache',
         'condition' => $this->config->readValue(['webserver', 'overwriteconfig']),
       ],
+      'mhout.json' => [
+        'dest' => $projectRoot . '/tests',
+      ],
     ];
   }
 
diff --git a/templates/docker-compose.yml.twig b/templates/docker-compose.yml.twig
index a414180..2678fe6 100644
--- a/templates/docker-compose.yml.twig
+++ b/templates/docker-compose.yml.twig
@@ -159,6 +159,11 @@ services:
 
   mailhog:
     image: 'mailhog/mailhog'
+    environment:
+      MH_OUTGOING_SMTP: /test/mhout.json
+    privileged: true
+    volumes:
+      - {{ projectroot }}/tests/mhout.json:/test/mhout.json
     labels:
       traefik.enable: 'true'
       traefik.network: {{ projectname }}
diff --git a/templates/mhout.json.twig b/templates/mhout.json.twig
new file mode 100644
index 0000000..cee8e89
--- /dev/null
+++ b/templates/mhout.json.twig
@@ -0,0 +1,10 @@
+{
+  "MySMTP": {
+    "name": "MySMTP",
+    "host": "{{ mailhog.host }}",
+    "port": "{{ mailhog.port }}",
+    "username": "{{ mailhog.username }}",
+    "password": "{{ mailhog.password }}",
+    "mechanism": "{{ mailhog.mechanism }}"
+  }
+}
-- 
GitLab