Repository: Mailu/Mailu

Issue:
[master] webmail page returns HTTP500 error when domain name contains an umlaut.
## Environment & Versions
### Environment
 - [x] docker-compose
 - [ ] kubernetes
 - [ ] docker swarm

### Versions
master

## Description
Webmail cannot be accessed when the domain name contains an umlaut. It does not matter if you login with the normal name or ACE notation (exämple.io vs xn--exmple-cua.io)

## Replication Steps
1). On test.mailu.io I created domain exämple.io .
2). Create user1 on this domain exämple.
3). Try going to webmail as user1@exämple.io. HTTP500 error. Admin page is accessible.
4). Try going to webmail as user1@xn--exmple-cua.io. Admin page is accessible. HTTP500 error for webmail.

1). On test.mailu.io I created domain xn--exmple-cua.io . After adding the domain, I noted that the domains page nicely shows exämple as the domain name.
2). Create user1 on this domain exämple.
3). Try going to webmail as user1@exämple.io. HTTP500 error. Admin page is accessible.
4). Try going to webmail as user1@xn--exmple-cua.io. Admin page is accessible. HTTP500 error for webmail.

## Expected behaviour
Webmail is reachable.

## Logs
webmail no errors. Possibly the logging is not correctly configured?
```
webmail_1     | 192.168.203.5 - - [26/Aug/2021:11:34:46 +0000] "POST /?_task=mail&_action=refresh HTTP/1.1" 200 620 "https://test.mailu.io/webmail/?_task=mail&_mbox=INBOX" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:11:35:04 +0000] "GET / HTTP/1.1" 302 577 "-" "curl/7.74.0"
```
front. Maybe the error "*5228 auth request unexpected status: 500 while sending to client," is relevant?
```
front_1       | 2021/08/26 11:37:41 [error] 13#13: *5228 auth request unexpected status: 500 while sending to client, client: 172.18.0.2, server: , request: "GET /webmail/ HTTP/1.1", host: "test.mailu.io", referrer: "https://test.mailu.io/admin/ui/user/settings"
front_1       | 172.18.0.2 - - [26/Aug/2021:11:37:41 +0000] "GET /webmail/ HTTP/1.1" 500 170 "https://test.mailu.io/admin/ui/user/settings" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 2021/08/26 11:37:43 [info] 13#13: *6413 client 87.246.7.228:64784 connected to 0.0.0.0:25
front_1       | 2021/08/26 11:37:43 [error] 13#13: *6413 "net6-ip228.linkbg.com" could not be resolved (3: Host not found) while in resolving client hostname, client: 87.246.7.228, server: 0.0.0.0:25
front_1       | 2021/08/26 11:37:46 [info] 13#13: *6417 client 192.168.203.12:43612 connected to 0.0.0.0:10143
front_1       | 127.0.0.1 - - [26/Aug/2021:11:37:46 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 2021/08/26 11:37:46 [info] 13#13: *6417 client logged in, client: 192.168.203.12, server: 0.0.0.0:10143, login: "admin@test.mailu.io", upstream: 192.168.203.7:143
front_1       | 2021/08/26 11:37:46 [info] 13#13: *6417 proxied session done, client: 192.168.203.12, server: 0.0.0.0:10143, login: "admin@test.mailu.io", upstream: 192.168.203.7:143
front_1       | 172.18.0.2 - - [26/Aug/2021:11:37:46 +0000] "POST /webmail/?_task=mail&_action=refresh HTTP/1.1" 200 124 "https://test.mailu.io/webmail/?_task=mail&_mbox=INBOX" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
front_1       | 2021/08/26 11:37:46 [info] 13#13: *6409 client login failed: "AUTH not supported" while in http auth state, client: 212.70.149.88, server: 0.0.0.0:25, login: "georgia@mailu.io"
front_1       | 127.0.0.1 - - [26/Aug/2021:11:37:46 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 127.0.0.1 - - [26/Aug/2021:11:37:47 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 2021/08/26 11:37:47 [info] 13#13: *6410 client login failed: "AUTH not supported" while in http auth state, client: 87.246.7.245, server: 0.0.0.0:25, login: "ninja@mailu.io"
front_1       | 127.0.0.1 - - [26/Aug/2021:11:37:50 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 2021/08/26 11:37:50 [info] 13#13: *6411 client login failed: "AUTH not supported" while in http auth state, client: 212.70.149.56, server: 0.0.0.0:25, login: "pmi@mailu.io"
front_1       | 127.0.0.1 - - [26/Aug/2021:11:37:51 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
```

admin
```
admin_1       | 127.0.0.1 - - [26/Aug/2021:11:38:38 +0000] "GET /ui/login?next=ui.index HTTP/1.1" 200 3745 "-" "curl/7.78.0"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:38:39 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 206.190.233.240 - - [26/Aug/2021:11:38:45 +0000] "GET /internal/auth/user HTTP/1.0" 200 0 "https://test.mailu.io/webmail/?_task=mail&_mbox=INBOX" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:38:46 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.7 - - [26/Aug/2021:11:38:46 +0000] "GET /internal/dovecot/passdb/admin@test.mailu.io HTTP/1.1" 200 67 "-" "Python/3.9 aiohttp/3.7.4.post0"
admin_1       | 192.168.203.7 - - [26/Aug/2021:11:38:46 +0000] "GET /internal/dovecot/userdb/admin@test.mailu.io HTTP/1.1" 200 36 "-" "Python/3.9 aiohttp/3.7.4.post0"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:38:47 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:38:48 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:38:51 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:38:52 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:05 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:08 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 127.0.0.1 - - [26/Aug/2021:11:39:09 +0000] "GET /ui/login?next=ui.index HTTP/1.1" 200 3745 "-" "curl/7.78.0"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:12 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:14 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:23 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:28 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:32 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:36 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 127.0.0.1 - - [26/Aug/2021:11:39:39 +0000] "GET /ui/login?next=ui.index HTTP/1.1" 200 3745 "-" "curl/7.78.0"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:43 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 206.190.233.240 - - [26/Aug/2021:11:39:45 +0000] "GET /internal/auth/user HTTP/1.0" 200 0 "https://test.mailu.io/webmail/?_task=mail&_mbox=INBOX" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:46 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.7 - - [26/Aug/2021:11:39:46 +0000] "GET /internal/dovecot/passdb/admin@test.mailu.io HTTP/1.1" 200 67 "-" "Python/3.9 aiohttp/3.7.4.post0"
admin_1       | 192.168.203.7 - - [26/Aug/2021:11:39:46 +0000] "GET /internal/dovecot/userdb/admin@test.mailu.io HTTP/1.1" 200 36 "-" "Python/3.9 aiohttp/3.7.4.post0"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:48 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:11:39:53 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"

```




Discussion:
Again the logs with the same time range
admin:
```
admin_1       | 172.18.0.2 - - [26/Aug/2021:12:08:17 +0000] "GET /ui/ HTTP/1.1" 302 265 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
admin_1       | 172.18.0.2 - - [26/Aug/2021:12:08:17 +0000] "GET /ui/login?next=ui.index HTTP/1.1" 200 3781 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
admin_1       | 192.168.203.5 - - [26/Aug/2021:12:08:17 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 172.18.0.2 - - [26/Aug/2021:12:08:17 +0000] "GET /ui/static/app.css HTTP/1.1" 200 0 "https://test.mailu.io/admin/ui/login?next=ui.index" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
admin_1       | 127.0.0.1 - - [26/Aug/2021:12:08:20 +0000] "GET /ui/login?next=ui.index HTTP/1.1" 200 3745 "-" "curl/7.78.0"
admin_1       | 192.168.203.5 - - [26/Aug/2021:12:08:20 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 172.18.0.2 - - [26/Aug/2021:12:08:24 +0000] "POST /ui/login?next=ui.index HTTP/1.1" 302 227 "https://test.mailu.io/admin/ui/login?next=ui.index" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
admin_1       | 172.18.0.2 - - [26/Aug/2021:12:08:24 +0000] "GET /ui/ HTTP/1.1" 302 253 "https://test.mailu.io/admin/ui/login?next=ui.index" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
admin_1       | 172.18.0.2 - - [26/Aug/2021:12:08:24 +0000] "GET /ui/user/settings HTTP/1.1" 200 7182 "https://test.mailu.io/admin/ui/login?next=ui.index" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
admin_1       | [2021-08-26 12:08:27 +0000] [10] [ERROR] Error handling request /internal/auth/user
admin_1       | Traceback (most recent call last):
admin_1       |   File "/usr/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 279, in handle
admin_1       |     keepalive = self.handle_request(req, conn)
admin_1       |   File "/usr/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 336, in handle_request
admin_1       |     resp.close()
admin_1       |   File "/usr/lib/python3.9/site-packages/gunicorn/http/wsgi.py", line 409, in close
admin_1       |     self.send_headers()
admin_1       |   File "/usr/lib/python3.9/site-packages/gunicorn/http/wsgi.py", line 329, in send_headers
admin_1       |     util.write(self.sock, util.to_bytestring(header_str, "ascii"))
admin_1       |   File "/usr/lib/python3.9/site-packages/gunicorn/util.py", line 507, in to_bytestring
admin_1       |     return value.encode(encoding)
admin_1       | UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 154: ordinal not in range(128)
admin_1       | 192.168.203.5 - - [26/Aug/2021:12:08:27 +0000] "GET /internal/auth/user HTTP/1.0" 500 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:12:08:31 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:12:08:34 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
admin_1       | 192.168.203.5 - - [26/Aug/2021:12:08:34 +0000] "GET /internal/auth/email HTTP/1.0" 200 0 "-" "-"
```
webmail:
```
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:07 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:38 +0000] "GET / HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:38 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:38 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:38 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:39 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:39 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:39 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:40 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:40 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:40 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:41 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:41 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:41 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:42 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:42 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:42 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:43 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:43 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:43 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:44 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:44 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:44 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:44 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:45 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:45 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:46 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 192.168.203.5 - - [26/Aug/2021:12:08:45 +0000] "POST /?_task=mail&_action=refresh HTTP/1.1" 200 620 "https://test.mailu.io/webmail/?_task=mail&_mbox=INBOX" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:46 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
webmail_1     | 127.0.0.1 - - [26/Aug/2021:12:08:47 +0000] "GET /sso.php HTTP/1.1" 302 577 "-" "curl/7.74.0"
```
front:
```
front_1       | 127.0.0.1 - - [26/Aug/2021:12:08:14 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 2021/08/26 12:08:14 [info] 13#13: *8261 client login failed: "AUTH not supported" while in http auth state, client: 212.70.149.56, server: 0.0.0.0:25, login: "james@mailu.io"
front_1       | 172.18.0.2 - - [26/Aug/2021:12:08:17 +0000] "GET /admin/ HTTP/1.1" 301 162 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 172.18.0.2 - - [26/Aug/2021:12:08:17 +0000] "GET /admin/ui/ HTTP/1.1" 302 265 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 172.18.0.2 - - [26/Aug/2021:12:08:17 +0000] "GET /admin/ui/login?next=ui.index HTTP/1.1" 200 3781 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 127.0.0.1 - - [26/Aug/2021:12:08:17 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 2021/08/26 12:08:17 [info] 13#13: *8263 client login failed: "AUTH not supported" while in http auth state, client: 87.246.7.245, server: 0.0.0.0:25, login: "rw@mailu.io"
front_1       | 172.18.0.2 - - [26/Aug/2021:12:08:17 +0000] "GET /admin/ui/static/app.css HTTP/1.1" 200 322 "https://test.mailu.io/admin/ui/login?next=ui.index" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 2021/08/26 12:08:20 [info] 13#13: *8246 client login failed: "Authentication credentials invalid" while in http auth state, client: 212.70.149.71, server: 0.0.0.0:465, login: "deploy@mailu.io"
front_1       | 127.0.0.1 - - [26/Aug/2021:12:08:20 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 2021/08/26 12:08:23 [info] 13#13: *8283 client 87.246.7.228:64408 connected to 0.0.0.0:25
front_1       | 2021/08/26 12:08:23 [error] 13#13: *8283 "net6-ip228.linkbg.com" could not be resolved (3: Host not found) while in resolving client hostname, client: 87.246.7.228, server: 0.0.0.0:25
front_1       | 172.18.0.2 - - [26/Aug/2021:12:08:24 +0000] "POST /admin/ui/login?next=ui.index HTTP/1.1" 302 227 "https://test.mailu.io/admin/ui/login?next=ui.index" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 172.18.0.2 - - [26/Aug/2021:12:08:24 +0000] "GET /admin/ui/ HTTP/1.1" 302 253 "https://test.mailu.io/admin/ui/login?next=ui.index" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 172.18.0.2 - - [26/Aug/2021:12:08:24 +0000] "GET /admin/ui/user/settings HTTP/1.1" 200 7182 "https://test.mailu.io/admin/ui/login?next=ui.index" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 2021/08/26 12:08:25 [info] 13#13: *7066 sendfile() failed (32: Broken pipe) while sending response to client, client: 172.18.0.2, server: , request: "GET /favicon.ico HTTP/1.1", host: "test.mailu.io", referrer: "https://test.mailu.io/admin/ui/user/settings"
front_1       | 172.18.0.2 - - [26/Aug/2021:12:08:25 +0000] "GET /favicon.ico HTTP/1.1" 200 0 "https://test.mailu.io/admin/ui/user/settings" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 2021/08/26 12:08:25 [info] 13#13: *8287 client 212.70.149.88:26708 connected to 0.0.0.0:25
front_1       | 2021/08/26 12:08:25 [error] 13#13: *8287 212.70.149.88 could not be resolved (3: Host not found) while in resolving client address, client: 212.70.149.88, server: 0.0.0.0:25
front_1       | 2021/08/26 12:08:25 [info] 13#13: *8288 client 212.70.149.56:52312 connected to 0.0.0.0:25
front_1       | 2021/08/26 12:08:25 [error] 13#13: *8288 212.70.149.56 could not be resolved (3: Host not found) while in resolving client address, client: 212.70.149.56, server: 0.0.0.0:25
front_1       | 2021/08/26 12:08:27 [info] 13#13: *8289 client 172.18.0.2 closed keepalive connection
front_1       | 172.18.0.2 - - [26/Aug/2021:12:08:27 +0000] "GET /webmail HTTP/1.1" 301 162 "https://test.mailu.io/admin/ui/user/settings" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 172.18.0.2 - - [26/Aug/2021:12:08:27 +0000] "GET /webmail/ HTTP/1.1" 500 170 "https://test.mailu.io/admin/ui/user/settings" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
front_1       | 2021/08/26 12:08:27 [error] 13#13: *8290 auth request unexpected status: 500 while sending to client, client: 172.18.0.2, server: , request: "GET /webmail/ HTTP/1.1", host: "test.mailu.io", referrer: "https://test.mailu.io/admin/ui/user/settings"
front_1       | 2021/08/26 12:08:29 [info] 13#13: *8292 client 87.246.7.245:54410 connected to 0.0.0.0:25
front_1       | 2021/08/26 12:08:29 [error] 13#13: *8292 "ip245.tervelnet.com" could not be resolved (3: Host not found) while in resolving client hostname, client: 87.246.7.245, server: 0.0.0.0:25
front_1       | 127.0.0.1 - - [26/Aug/2021:12:08:31 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 2021/08/26 12:08:31 [info] 13#13: *8283 client login failed: "AUTH not supported" while in http auth state, client: 87.246.7.228, server: 0.0.0.0:25, login: "boc@mailu.io"
front_1       | 2021/08/26 12:08:34 [info] 13#13: *8287 client login failed: "AUTH not supported" while in http auth state, client: 212.70.149.88, server: 0.0.0.0:25, login: "awstats@mailu.io"
front_1       | 127.0.0.1 - - [26/Aug/2021:12:08:34 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 127.0.0.1 - - [26/Aug/2021:12:08:34 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 2021/08/26 12:08:34 [info] 13#13: *8288 client login failed: "AUTH not supported" while in http auth state, client: 212.70.149.56, server: 0.0.0.0:25, login: "itm@mailu.io"
front_1       | 127.0.0.1 - - [26/Aug/2021:12:08:37 +0000] "GET /auth/email HTTP/1.0" 200 0 "-" "-"
front_1       | 2021/08/26 12:08:37 [info] 13#13: *8292 client login failed: "AUTH not supported" while in http auth state, client: 87.246.7.245, server: 0.0.0.0:25, login: "audit@mailu.io"
front_1       | 127.0.0.1 - - [26/Aug/2021:12:08:41 +0000] "GET /health HTTP/1.1" 204 0 "-" "curl/7.78.0"
front_1       | 2021/08/26 12:08:41 [info] 13#13: *8305 client 127.0.0.1 closed keepalive connection
```
The error refers to https://github.com/Mailu/Mailu/blob/ecb39fed04b6ec4d486556044ccaf2102cde6196/core/admin/mailu/internal/views/auth.py#L52 .
It complains about the ä. 

Only ASCII is allowed in HTTP headers. In auth.py we add the full username as a header (localpart@domain).

A solution would be to base64 encode the user name. In the php (in roundcube/rainloop?) decode the base64 encoded username in the HTTP header.

Resolving patch:
diff --git a/core/admin/mailu/internal/views/auth.py b/core/admin/mailu/internal/views/auth.py
--- a/core/admin/mailu/internal/views/auth.py
+++ b/core/admin/mailu/internal/views/auth.py
@@ -50,7 +50,7 @@ def user_authentication():
     if (not flask_login.current_user.is_anonymous
         and flask_login.current_user.enabled):
         response = flask.Response()
-        response.headers["X-User"] = flask_login.current_user.get_id()
+        response.headers["X-User"] = models.IdnaEmail.process_bind_param(flask_login, flask_login.current_user.get_id(), "")
         response.headers["X-User-Token"] = models.User.get_temp_token(flask_login.current_user.get_id())
         return response
     return flask.abort(403)
@@ -67,7 +67,7 @@ def basic_authentication():
         user = models.User.query.get(user_email.decode("utf8"))
         if nginx.check_credentials(user, password.decode('utf-8'), flask.request.remote_addr, "web"):
             response = flask.Response()
-            response.headers["X-User"] = user.email
+            response.headers["X-User"] = models.IdnaEmail.process_bind_param(flask_login, user.email, "")
             return response
     response = flask.Response(status=401)
     response.headers["WWW-Authenticate"] = 'Basic realm="Login Required"'


Test patch: