I’m not sure but here’s what ChatGPT suggests:
Thanks for the detailed context! You’re absolutely right that the issue is firewall-related, especially since email works when it’s disabled.
You’re running the Invoice Ninja container via Portainer on a Synology NAS, and Gmail SMTP works only when the firewall is disabled — so the issue is most likely that port 587 (TLS) isn’t properly allowed for outbound traffic.
Here are some ideas and steps to fix this:
1. Double-check the Synology NAS firewall rules
Synology’s firewall UI can be a bit tricky. Make sure:
- You add an “allow” rule for outbound traffic on port 587.
- The rule should allow traffic from the Docker network / container to external addresses (like
smtp.gmail.com
).
Tip: Synology firewall rules are evaluated top-down, so make sure your allow rule comes before any “deny all” rules.
2. Verify that Docker is using the correct network
Sometimes Docker containers don’t use the NAS’s main network interface. You can try assigning the container to a bridge or host network that has proper access. Here’s how to check:
- In Portainer, go to your Invoice Ninja container > Network
- See what network mode it’s using (bridge, host, macvlan, etc.)
- Try switching to host mode for testing — this will use the NAS’s network stack directly and can bypass some container-network limitations
3. Test the port manually from within the container
To confirm that port 587 is blocked inside the container, you can run:
docker exec -it <container_id_or_name> bash
Then inside:
apt update && apt install telnet -y
telnet smtp.gmail.com 587
If this fails while the firewall is up, but works when the firewall is off, you 100% know it’s the NAS firewall.
4. Alternative Ports
Gmail supports:
- Port 465 (SSL)
- Port 587 (TLS)
Try switching to port 465 and changing your encryption method to SSL in the .env
or UI settings to see if it bypasses the firewall block.
5. Temporarily log dropped connections
To debug further, you can enable firewall logging on Synology:
- Go to Control Panel > Security > Firewall > Edit Rules
- Enable logging for dropped packets (you may need to SSH in and check
/var/log/messages
)
This will show what’s being blocked.
Let me know what your firewall rules currently look like (screenshot or description), and I can help tweak them!