126

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...

3
  • seems -f is flush and -q is queue (send the queue)
    – m3nda
    Apr 9, 2015 at 5: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. Apr 24, 2015 at 18:15
  • Sorry again, comment on the same day :) so both are wrong.
    – m3nda
    Apr 24, 2015 at 20:45

6 Answers 6

150

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.

0
50

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.

0
17

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

7
  • Isn't this the same as running postqueue -f ? May 30, 2014 at 12:22
  • 2
    @NoICE it is. From the docs: -q Attempt to deliver all queued mail. This is implemented by executing the postqueue(1) command.
    – the-wabbit
    May 30, 2014 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 9, 2015 at 5: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. " Apr 24, 2015 at 18:11
  • @JohannesH. Doh... sorry, you're right about i should read it. Thank you for the correction.
    – m3nda
    Apr 24, 2015 at 20:44
7

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.
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. Jun 23, 2021 at 8: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?

0

You can do an immediate resend of an email in the queue, will keep same ID:

postqueue -i ID

You can do a re-queue, will get a new ID, in some cases for example after adding a sender_canonical, resending isn't enough, you have to re-queue:

postsuper -r ID

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .