diff --git a/tests/email.sh b/tests/email.sh
index 142af0acce6970f6d8aa81b371addc865c7cd596..00aa2d093c395c9225870488f93ae34a2ef7f2ea 100755
--- a/tests/email.sh
+++ b/tests/email.sh
@@ -1,7 +1,7 @@
 #!/bin/bash -eux
 
 mkdir -p /data/domains/mail/dovecot
-mkdir -p /data/domains/mail/TLS
+mkdir -p /data/domains/mail/TLS/
 mkdir -p /data/domains/mail/static/www-content
 mkdir -p /data/runtime/domains/mail/mysql/db_files
 mkdir -p /data/domains/mail/mysql
@@ -22,7 +22,7 @@ openssl x509 -req -days 365 \
   -in /data/domains/mail/TLS/ssl_cert_sign_req.csr -signkey /data/domains/mail/TLS/ssl_private_key.pem -out /data/domains/mail/TLS/ssl_certificate.pem
 openssl dhparam -out /data/domains/mail/TLS/dh2048.pem 2048
 
-cp /data/domains/mail/TLS/ssl_certificate.pem /data/domains/mail/TLS/mail.pem
+cat /data/domains/mail/TLS/ssl_certificate.pem /data/domains/mail/TLS/ssl_private_key.pem > /data/domains/mail/TLS/mail.pem
 
 systemctl enable dovecot
 systemctl enable postfix