diff --git a/src/Handler.php b/src/Handler.php index 0be678b75563a897a438c53fb0f5aeaeb587f900..7ab602ebd090029c0769646f47075b8a4117be8b 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -126,13 +126,26 @@ class Handler extends BaseHandler { 'overwriteconfig' => FALSE, ], 'mailhog' => [ - 'enable' => 1, + 'enable' => 0, 'host' => $this->env->receiveGlobal('MAILHOG_HOST', 'MailHog Host', 'smtp.freesmtpservers.com'), 'port' => $this->env->receiveGlobal('MAILHOG_PORT', 'MailHog Port', '25'), 'username' => $this->env->receiveGlobal('MAILHOG_USERNAME', 'MailHog Username'), 'password' => $this->env->receiveGlobal('MAILHOG_PASSWORD', 'MailHog Password'), 'mechanism' => $this->env->receiveGlobal('MAILHOG_MECHANISM', 'MailHog Auth Mechanism', 'NONE'), ], + 'mailpit' => [ + 'enable' => 1, + 'host' => $this->env->receiveGlobal('MAILPIT_HOST', 'MailPit Host', 'smtp.freesmtpservers.com'), + 'port' => $this->env->receiveGlobal('MAILPIT_PORT', 'MailPit Port', '25'), + 'username' => $this->env->receiveGlobal('MAILPIT_USERNAME', 'MailPit Username'), + 'password' => $this->env->receiveGlobal('MAILPIT_PASSWORD', 'MailPit Password'), + 'starttls' => $this->env->receiveGlobal('MAILPIT_STARTTLS', 'MailPit StartTLS'), + 'allowinsecure' => $this->env->receiveGlobal('MAILPIT_ALLOW_INSECURE', 'MailPit allow insecure'), + 'auth' => $this->env->receiveGlobal('MAILPIT_AUTH', 'MailPit Auth (none|plain|login|cram-md5)'), + 'secret' => $this->env->receiveGlobal('MAILPIT_SECRET', 'MailPit Secret'), + 'returnpath' => $this->env->receiveGlobal('MAILPIT_RETURNPATH', 'MailPit Bounce Address'), + 'recipientallowlist' => $this->env->receiveGlobal('MAILPIT_RECIPIENT_ALLOW_LIST', 'MailPit Regex for allowed recipients'), + ], 'varnish' => [ 'enable' => 0, ], @@ -613,6 +626,9 @@ class Handler extends BaseHandler { 'mhout.json' => [ 'dest' => $projectRoot . '/tests', ], + 'mailpitout.yml' => [ + 'dest' => $projectRoot . '/tests', + ], ]; $files['cypress.config.js'] = [ 'source' => 'tests/', diff --git a/templates/docker-compose.yml.twig b/templates/docker-compose.yml.twig index 43f5c2695dbccfe9adf3ef40ef9c0da7b2b24c97..c427d90408cdcf157e2b934614c2ca7607d377a9 100644 --- a/templates/docker-compose.yml.twig +++ b/templates/docker-compose.yml.twig @@ -51,6 +51,8 @@ services: environment: {% if mailhog.enable %} PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 +{% elseif mailpit.enable %} + PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailpit:1025 {% endif %} DB_HOST: mariadb DB_USER: drupal @@ -295,8 +297,8 @@ services: traefik.http.routers.solr-{{ projectname }}.tls.certresolver: lakedrops {% endif %} {% endif %} - {% if mailhog.enable and (not drupal.live|default(0) or staging) %} + mailhog: image: '{{ docker_image_prefix }}mailhog/mailhog' {% if staging %} @@ -325,6 +327,36 @@ services: traefik.http.routers.mailhog-{{ projectname }}.tls: 'true' traefik.http.routers.mailhog-{{ projectname }}.tls.certresolver: lakedrops {% endif %} +{% elseif mailpit.enable and (not drupal.live|default(0) or staging) %} + + mailpit: + image: '{{ docker_image_prefix }}axllent/mailpit' +{% if staging %} + restart: unless-stopped +{% endif %} + networks: + - traefik-public + - default + environment: + MP_SMTP_RELAY_CONFIG: /test/mailpitout.yml + privileged: true + volumes: + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + - {{ projectroot }}/tests/mailpitout.yml:/test/mailpitout.yml + labels: + traefik.enable: 'true' + traefik.docker.network: traefik-public +{% if basicauth.enable %} + traefik.http.middlewares.mailpit-{{ projectname }}-auth.basicauth.users: {{ basicauth.code }} + traefik.http.routers.mailpit-{{ projectname }}.middlewares: mailpit-{{ projectname }}-auth@docker +{% endif %} + traefik.http.services.{{ projectname }}_mailpit.loadbalancer.server.port: 8025 + traefik.http.routers.mailpit-{{ projectname }}.rule: Host(`mailpit-{{ projectdomain }}`) +{% if drupal.live|default(0) or traefik.usessl %} + traefik.http.routers.mailpit-{{ projectname }}.tls: 'true' + traefik.http.routers.mailpit-{{ projectname }}.tls.certresolver: lakedrops +{% endif %} {% endif %} {% if node.enable %} diff --git a/templates/mailpitout.yml.twig b/templates/mailpitout.yml.twig new file mode 100644 index 0000000000000000000000000000000000000000..4fa8b29616b805562b98dfee919fb0832ddd39f3 --- /dev/null +++ b/templates/mailpitout.yml.twig @@ -0,0 +1,28 @@ +host: '{{ mailpit.host }}' +{% if mailpit.port != '' %} +port: {{ mailpit.port }} +{% endif %} +{% if mailpit.username != '' %} +username: '{{ mailpit.username }}' +{% endif %} +{% if mailpit.password != '' %} +password: '{{ mailpit.password }}' +{% endif %} +{% if mailpit.starttls != '' %} +starttls: {{ mailpit.starttls }} +{% endif %} +{% if mailpit.allowinsecure != '' %} +allow-insecure: {{ mailpit.allowinsecure }} +{% endif %} +{% if mailpit.auth != '' %} +auth: '{{ mailpit.auth }}' +{% endif %} +{% if mailpit.secret != '' %} +secret: '{{ mailpit.secret }}' +{% endif %} +{% if mailpit.returnpath != '' %} +return-path: '{{ mailpit.returnpath }}' +{% endif %} +{% if mailpit.recipientallowlist != '' %} +recipient-allowlist: '{{ mailpit.recipientallowlist }}' +{% endif %} diff --git a/templates/settings.docker.php.twig b/templates/settings.docker.php.twig index 3cb6b49cf1deb0b06e6ba77e92d161856ce6d40d..709248a48c6c3780c35a746fe5b7d4beca3b0e40 100644 --- a/templates/settings.docker.php.twig +++ b/templates/settings.docker.php.twig @@ -33,10 +33,10 @@ $databases = array( ), ), ); -{% if not drupal.live|default(0) or mailhog.enable %} +{% if not drupal.live|default(0) or mailhog.enable or mailpit.enable %} $config['system.mail']['interface']['default'] = 'SMTPMailSystem'; $config['smtp.settings']['smtp_on'] = TRUE; -$config['smtp.settings']['smtp_host'] = 'mailhog'; +$config['smtp.settings']['smtp_host'] = '{% if mailhog.enable %}mailhog{% else %}mailpit{% endif %}'; $config['smtp.settings']['smtp_hostbackup'] = ''; $config['smtp.settings']['smtp_port'] = '1025'; $config['smtp.settings']['smtp_protocol'] = 'standard'; @@ -65,7 +65,7 @@ $databases = array( ); $base_url = '{{ projectprotocol }}://{{ projectdomain }}{{ projectport }}'; -$conf['smtp_host'] = 'mailhog'; +$conf['smtp_host'] = '{% if mailhog.enable %}mailhog{% else %}mailpit{% endif %}'; $conf['smtp_hostbackup'] = ''; $conf['smtp_port'] = '1025'; $conf['smtp_protocol'] = 'standard';