diff --git a/ci/image-tests/Checks/PostfixChecks.php b/ci/image-tests/Checks/PostfixChecks.php index 9fb67b64f..678fe4b31 100644 --- a/ci/image-tests/Checks/PostfixChecks.php +++ b/ci/image-tests/Checks/PostfixChecks.php @@ -54,6 +54,22 @@ public function testMailFromPhpFpmReachesTheRelayHost(): void $this->assertMailArrived('fpm-fcgi', $container); } + /** + * A mail with UTF-8 in its subject reaches the relay host, which, like many mail catchers, does not offer + * SMTPUTF8. + */ + public function testMailWithUtf8InTheSubjectReachesTheRelayHost(): void + { + $container = $this->mailContainer(); + self::assertSame('sent', $this->stdout( + "php -r 'echo mail(\"someone@example.test\", \"Image test with UTF-8: Grüße\", \"Sent by the image tests\") ? \"sent\" : \"not sent\";' 2>/dev/null", + $container, + )); + $this->waitFor(function () use ($container): void { + self::assertStringContainsString('Subject: Image test with UTF-8: Grüße', $this->stdout('cat /tmp/image-tests/mail/*.eml 2>/dev/null || true', $container)); + }); + } + /** * The environment container with the SMTP sink running. A second sink exits, because the port is taken. */ diff --git a/docker/base/alpine/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/alpine/conf/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/docker/base/alpine/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/base/alpine/conf/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST diff --git a/docker/base/ubuntu-22.04/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/ubuntu-22.04/conf/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/docker/base/ubuntu-22.04/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/base/ubuntu-22.04/conf/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST diff --git a/docker/php-official/8.2-alpine/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/8.2-alpine/conf/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/docker/php-official/8.2-alpine/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/php-official/8.2-alpine/conf/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST diff --git a/docker/php-official/8.2/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/8.2/conf/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/docker/php-official/8.2/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/php-official/8.2/conf/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST diff --git a/docker/php-official/8.3-alpine/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/8.3-alpine/conf/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/docker/php-official/8.3-alpine/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/php-official/8.3-alpine/conf/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST diff --git a/docker/php-official/8.3/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/8.3/conf/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/docker/php-official/8.3/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/php-official/8.3/conf/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST diff --git a/docker/php-official/8.4-alpine/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/8.4-alpine/conf/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/docker/php-official/8.4-alpine/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/php-official/8.4-alpine/conf/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST diff --git a/docker/php-official/8.4/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/8.4/conf/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/docker/php-official/8.4/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/php-official/8.4/conf/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST diff --git a/docker/php-official/8.5-alpine/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/8.5-alpine/conf/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/docker/php-official/8.5-alpine/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/php-official/8.5-alpine/conf/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST diff --git a/docker/php-official/8.5/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/8.5/conf/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/docker/php-official/8.5/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/php-official/8.5/conf/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST diff --git a/docs/images/php.md b/docs/images/php.md index b725a236a..fe6aeedc7 100644 --- a/docs/images/php.md +++ b/docs/images/php.md @@ -180,6 +180,8 @@ services: The `-dev` images start Postfix. It has no relay host and delivers each message directly to the recipient's mail server. +Postfix does not use SMTPUTF8 (`smtputf8_enable = no`), so a message with UTF-8 in its headers, for example in the subject, also reaches a relay host or mail catcher that does not offer it. + > [!WARNING] > Without a relay host, Postfix in a development container tries to deliver mail to real recipients. Send it to a mail catcher such as [Mailpit](https://mailpit.axllent.org/) instead. diff --git a/provisioning/base/general/bin/service.d/postfix.d/10-init.sh b/provisioning/base/general/bin/service.d/postfix.d/10-init.sh index 82574153d..e1951d0ec 100644 --- a/provisioning/base/general/bin/service.d/postfix.d/10-init.sh +++ b/provisioning/base/general/bin/service.d/postfix.d/10-init.sh @@ -6,10 +6,12 @@ cp -f /etc/services /var/spool/postfix/etc/services go-replace --mode=line --regex -s '^[\s]*myhostname[\s]*=.*' -r "myhostname = $HOSTNAME" -# General +# General; without SMTPUTF8, mail with UTF-8 in its headers also reaches a relay host that does not offer it, such +# as many mail catchers go-replace --mode=lineinfile --regex \ -s '^[\s]*myhostname[\s]*=.*.*' -r "myhostname = $HOSTNAME" \ -s '^[\s]*inet_interfaces[\s]*=.*' -r "inet_interfaces = 127.0.0.1" \ + -s '^[\s]*smtputf8_enable[\s]*=.*' -r "smtputf8_enable = no" \ -- /etc/postfix/main.cf ## REPLAYHOST