CodexBloom - Programming Q&A Platform

Postfix mail queue not processing emails on Ubuntu 20.04 with MySQL backend

👀 Views: 160 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-26
postfix ubuntu email bash

Could someone explain I'm integrating two systems and I'm experiencing an scenario with my Postfix mail server on Ubuntu 20.04 where emails are exploring in the mail queue and not being processed. I'm using a MySQL backend for virtual domains and users. When I check the mail queue with `mailq`, I see a lot of emails in status 'deferred'. The logs show entries like: ``` Jul 15 14:32:53 mail postfix/smtp[12345]: 1234567890: to=<recipient@example.com>, relay=none, delay=0.1, status=deferred (connect to mail.example.com[192.0.2.1]: No route to host) ``` I've confirmed that the DNS records for `mail.example.com` are correct and that I can ping the mail server's IP from the command line. I also checked the Postfix configuration in `/etc/postfix/main.cf`, and here are some relevant entries: ``` hostname = mail.example.com mydestination = localhost, localhost.localdomain, localhost relayhost = ``` I tried restarting the Postfix service using `sudo systemctl restart postfix`, and I've also run `postmap /etc/postfix/mysql_virtual_alias_maps.cf` to ensure the database maps are up-to-date, but the scenario continues. I suspect it might be related to how Postfix is resolving the relay host or possibly a firewall rule blocking outgoing connections, but my iptables rules allow outgoing traffic. Here's what I see when I run `iptables -L`: ``` Chain INPUT (policy ACCEPT) Chain FORWARD (policy ACCEPT) Chain OUTPUT (policy ACCEPT) ``` Any guidance on how to debug this further or specific configurations I might be missing would be greatly appreciated. Any examples would be super helpful. I'm working with Bash in a Docker container on Debian. Any examples would be super helpful.