Outgoing mail to other servers stays in the queue
Mail to other servers stays in the queue, deferred with Connection timed out or Connection refused on port 25. When your hosting provider blocks outgoing connections on that port, you can restore Postfix delivery by asking the provider to open it or by using a smarthost.
Symptoms
Mail between mail accounts on the server arrives. Mail to other servers stays in the queue.
List the queue to see why each message was deferred.
urbestack-mail-queue-listThe delay_reason for an affected message looks like this.
connect to mx.example.net[198.51.100.7]:25: Connection timed outYou may also see Connection refused in delay_reason.
Cause
Postfix delivers mail to other servers on port 25. Many cloud and VPS providers block outgoing connections to port 25 by default or for new accounts.
Resolution
Test whether your server can reach port 25 on a receiving server.
timeout 10 bash -c 'cat < /dev/null > /dev/tcp/gmail-smtp-in.l.google.com/25' && echo "port 25 open" || echo "port 25 blocked"If the command prints
port 25 blocked, ask your hosting provider to open outgoing port 25.You can also send through a smarthost, a relay that accepts your server's mail on port 587. The command defaults to port 587 and requires TLS by default. It reads the relay's password from standard input.
urbestack-mail-smarthost-set --host smtp.relay.example --user relay-user --password-stdinUse
--name example.comto apply the smarthost to one domain only.Then retry every queued message at once.
urbestack-mail-queue-flushRun urbestack-mail-queue-list again and check that the queue empties.