119

I have a backup mail server in case of a failure on the main one. In that case of failure, mails come on the backup server and stay there until the main one is back.

If I wait some times, the delivery will be done automatically as soon as the main server is back but it can be long. So how to force a send retry of all the mails?

For exemple : postqueue -p : give me a list of mails

I then tried postqueue -f (from man page : Flush the queue: attempt to deliver all queued mail.). It surely flushed the queue but mails were not been delivered...

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
Nicolas
  • 1,199
  • 2
  • 7
  • 3
  • seems -f is flush and -q is queue (send the queue) – m3nda Apr 09 '15 at 05:32
  • 3
    there is no `postqueue -q`. There is `sendmail -q` to support sendmail syntax so postfix can completely replace sendmail, but that's a synonym. The different letters are jsut because postfix chose different ones than sendmail did. – Johannes H. Apr 24 '15 at 18:15
  • Sorry again, comment on the same day :) so both are wrong. – m3nda Apr 24 '15 at 20:45

5 Answers5

143

According to postqueue(1) you can simply run postqueue -f to flush your mail queue. If the mails aren't delivered after flushing the queue but are being requeued instead, you might want to check your mail logs for errors.

Taking a peek at postsuper(1) might also be helpful. Maybe the messages are on hold and need to be released first.

joschi
  • 20,747
  • 3
  • 46
  • 50
45

postqueue -f should work. If it does not, it has a good reason for that. Check the logs. Also pfqueue is a very useful command for inspecting mail spool.

starfry
  • 561
  • 1
  • 7
  • 13
Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
16

sendmail -q retries delivery of all mails in the queue immediately.

the-wabbit
  • 40,319
  • 13
  • 105
  • 169
  • Isn't this the same as running postqueue -f ? – Dalibor Filus May 30 '14 at 12:22
  • 2
    @NoICE it is. From [the docs](http://www.postfix.org/sendmail.1.html): *-q Attempt to deliver all queued mail. This is implemented by executing the postqueue(1) command.* – the-wabbit May 30 '14 at 18:26
  • I didn't check for that, but seems -f is flush and -q is queue. One tries to send then the other just clean the queue. It's better to try deliver i guess. – m3nda Apr 09 '15 at 05:31
  • 1
    @erm3nda You shoudl at least check the man pages first. From the `postqueue` man page: "-f Flush the queue: attempt to deliver all queued mail. This option implements the traditional "sendmail -q" command, by contacting the Postfix qmgr(8) daemon." => they are synonym and do exactly the same. " – Johannes H. Apr 24 '15 at 18:11
  • @JohannesH. Doh... sorry, you're right about i should read it. Thank you for the correction. – m3nda Apr 24 '15 at 20:44
  • I would prefer to use sendmail -q -v that will force retry with verbose. – Mansur Ul Hasan Apr 29 '15 at 14:08
  • This has the advantage of being more portable (it will work with other MTAs, not just postfix, so is better one to remember) – Matija Nalis Feb 02 '17 at 11:57
6

I'm usually using this command

postsuper -r ALL && postqueue -f

Parameters:

  • -r ALL is requeue all message
  • -f is Flush the queue: attempt to deliver all queued mail.
lubry
  • 61
  • 1
  • 1
  • 1
    Works for messages "stuck" in the queue with no attempts being made to resend them. Happened to me after a postfix update, somehow it has found old messages/queue that it didn't see before. Had to release them first before they could enter the queue proper. – Захар Joe Jun 23 '21 at 08:23
5

postqueue -s domain.tld should cause the backup relay machine to flush all the email for your site. The default setup for postfix enables per-site flushing for all domains in relay_domains. postqueue -f will do this too, but will also push out mail for external sites, i.e. it does more than you need.

How are you determining that mail has not been delivered? Are they still on the backup host or have they been sent to the main host and then got lost?

araqnid
  • 823
  • 5
  • 10