I am attempting to deploy the mattmckenzy/mail2gotify:latest Docker container to forward email notifications to my Gotify instance. The container consistently fails to start with a System.ArgumentException related to certificate files.
According to the README.md documentation, "TLS 1.2 or 1.3 is mandatory and Mail2Gotify will need a certificate to function. You can choose to point the 'CertLocation' variable to a valid PEM or PKCS7 certificate, or leave it empty to have Mail2Gotify create a self-signed one."
Despite following the documentation's instructions for self-signed certificate generation (leaving CertLocation empty) or providing dummy certificates, the service continuously fails.
Observed Behavior & Troubleshooting Steps:
Initial Attempt (similar to README example, without actually mounting certs):
When Services:Mail2Gotify:CertLocation and Services:Mail2Gotify:KeyLocation were present in environment but no corresponding /certs volume was mounted, the container failed with:
System.ArgumentException: The cert file configuration and set but the file doesn't exist! at Mail2Gotify.Services.Mail2GotifyService.StartAsync (Line 37)
Attempting Self-Signed Certificate Generation (as per documentation: "If left empty"):
Based on the README.md, I removed explicit CertLocation and KeyLocation parameters and added Services:SelfSignedCertificate:Name and Services:SelfSignedCertificate:Password.
Initially, this led to a System.NullReferenceException: Object reference not set to an instance of an object. at Mail2Gotify.Services.Mail2GotifyService.StartAsync (Line 60), suggesting missing mandatory configuration.
After careful re-reading and ensuring Services:SelfSignedCertificate:Name and Services:SelfSignedCertificate:Password were correctly set, the error reverted to the original System.ArgumentException: The cert file configuration and set but the file doesn't exist! (Line 37). This indicates the self-signed generation logic is not being triggered, or CertLocation is implicitly still expecting a file.
Attempting Explicitly Empty CertLocation:
I then explicitly set Services:Mail2Gotify:CertLocation="" while keeping Services:SelfSignedCertificate:Name and Services:SelfSignedCertificate:Password configured.
Result: Still the same System.ArgumentException: The cert file configuration and set but the file doesn't exist! (Line 37). This suggests that even an empty string is being interpreted as an invalid file path, rather than triggering self-signing.
Attempting to Mount Dummy Certificates:
I generated a dummy dummy_cert.crt and dummy_cert.key on the host and mounted them to /tmp_certs in the container, configuring CertLocation and KeyLocation to point to these files inside the container.
Result: The error persists: System.ArgumentException: The cert file configuration and set but the file doesn't exist! (Line 37). This is highly unexpected as the files do exist at the specified path within the container.
Additional Debugging Information:
docker inspect mail2gotify confirms that environment variables (e.g., Services:Mail2Gotify:CertLocation="", Services:SelfSignedCertificate:Name/Password, Services:Gotify:ServiceUri, Services:Gotify:Token) are correctly passed to the container as defined in compose.yaml.
My Gotify server (https://YOUR_GOTIFY_DOMAIN, Version 2.6.3) is fully reachable from the Docker host via curl, and can receive messages when tested manually (even with the unusual short application tokens it generates, which is a separate observation but indicates the Gotify server is functional).
All docker compose down --volumes --rmi all and docker system prune -a --volumes commands have been executed between attempts to ensure a clean state.
Expected Behavior:
Mail2Gotify should successfully start its SMTP server by generating a self-signed certificate, as stated in the documentation, when Services:Mail2Gotify:CertLocation is left empty or explicitly set to "", and Services:SelfSignedCertificate:Name/Password are provided.
Actual Behavior:
The container consistently fails to start, always returning System.ArgumentException: The cert file configuration and set but the file doesn't exist! at line 37, implying that the self-signed certificate generation is not occurring or the application is always attempting to load a non-existent file path, regardless of configuration.
Steps to Reproduce (using the latest attempt):
Create the compose.yaml file as follows:
YAML
volumes:
mail2gotify_cache: null
services:
mail2gotify:
container_name: mail2gotify
image: mattmckenzy/mail2gotify:latest
restart: always
network_mode: host
environment:
- Services:Gotify:ServiceUri=https://YOUR_GOTIFY_DOMAIN # Anonymisiert
- Services:Gotify:Token=YOUR_GOTIFY_APP_TOKEN # Anonymisiert (Ihr kurzer Token)
- Services:Mail2Gotify:HostAddress=0.0.0.0
- Services:Mail2Gotify:CacheDirectory=/cache
- Services:Mail2Gotify:HostPort=587
# Configuration for self-signed certificate generation (as per README)
- Services:Mail2Gotify:CertLocation="" # Explicitly empty to trigger self-signing
- Services:SelfSignedCertificate:Name="Mail2Gotify_App_Name" # Anonymisiert
- Services:SelfSignedCertificate:Password="YourSecureCertPassword" # Anonymisiert
- SMTP_AUTH_REQUIRED="false"
- TZ=Europe/Berlin
volumes:
- mail2gotify_cache:/cache
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
Execute the following commands:
Bash
docker compose down --volumes --rmi all
docker system prune -a --volumes # (Optional, but done for thoroughness)
docker pull mattmckenzy/mail2gotify:latest
docker compose up -d
docker compose logs mail2gotify -f
Environment:
Docker Version: 28.3.3
Docker Compose Version: 2.39.1
Host OS: Debian 12.11
Gotify Server Version: 2.6.3 (confirmed by curl and UI)
I am attempting to deploy the mattmckenzy/mail2gotify:latest Docker container to forward email notifications to my Gotify instance. The container consistently fails to start with a System.ArgumentException related to certificate files.
According to the README.md documentation, "TLS 1.2 or 1.3 is mandatory and Mail2Gotify will need a certificate to function. You can choose to point the 'CertLocation' variable to a valid PEM or PKCS7 certificate, or leave it empty to have Mail2Gotify create a self-signed one."
Despite following the documentation's instructions for self-signed certificate generation (leaving CertLocation empty) or providing dummy certificates, the service continuously fails.
Observed Behavior & Troubleshooting Steps:
Additional Debugging Information:
Expected Behavior:
Mail2Gotify should successfully start its SMTP server by generating a self-signed certificate, as stated in the documentation, when Services:Mail2Gotify:CertLocation is left empty or explicitly set to "", and Services:SelfSignedCertificate:Name/Password are provided.
Actual Behavior:
The container consistently fails to start, always returning System.ArgumentException: The cert file configuration and set but the file doesn't exist! at line 37, implying that the self-signed certificate generation is not occurring or the application is always attempting to load a non-existent file path, regardless of configuration.
Steps to Reproduce (using the latest attempt):
volumes:
mail2gotify_cache: null
services:
mail2gotify:
container_name: mail2gotify
image: mattmckenzy/mail2gotify:latest
restart: always
network_mode: host
Execute the following commands:
Bash
Environment: