Mac OS X Server (10.5) mail trapped in queue

mac-osxmac-osx-serverqueuesmtp

We've got mail accumulating in our Leopard Server's queue and not sure exactly why. This machine has required little maintenance over the years so I'm hoping someone here spot the obvious and save us some time. Let me know what other information would be helfull. Server appears to be functioning normally except for "clogged" queue and the following error associated with each "trapped" message:

Looking at messages in the queue each one states something like this:

Message ID: 4213C3B8B3F
Date:       October 27, 2009 11:33:27 AM
Size:       1824
Sender:     user@gmail.com
Recipient(s) & Status:
----------------------
user@ourdomain.com:
    connect to 127.0.0.1[127.0.0.1]: Connection refused

Under Settings>Relay we have checked Accept SMTP relays only from these hosts and networks:

127.0.0.0/8
10.0.1.0/24 

The mail in queue is addressed to users whose accounts are on this server. Mail.app on the client appears to be functioning normally and checking checking mail on the server. We did add a virtual domain some time ago but all that was working fine for some time… This just started happening recently…any ideas?

Edit: toggling the filter services on and off seems to have fixed this except for 2 remaining queued messages that show "mail transport unavailable" as an error!?!

Best Answer

We see this on occasion on our Mac OS X 10.5 Leopard Server mail server as well, usually after restarting the Mail service (I actually attribute it to a mailbfr issue, but haven't fully traced it to the root cause). What happens is that /var/amavis/tmp goes missing, causing amavisd to fail, thus preventing delivery. Simply recreating the tmp directory and restarting the Mail service works for us:

sudo mkdir /var/amavis/tmp
sudo chown _amavisd:_amavisd /var/amavis/tmp

As far as cleaning out the queue, I'd suggest getting comfortable with the postqueue & postsuper commands. postqueue -p will print the queue. sudo postsuper -r ALL will re-queue all the messages for delivery. I'd suggest not running the latter when you have a massive number of messages in the queue, but once the queue clears out and you just have a couple that haven't been resent yet.