I have a quick question. How does one add emails to Postfix's queue without it delivering the emails? I am writing a script to email Postfix statistics (queue count, sent, etc) to our support staff. I want to test it when there are emails in Postfix's queue to see if its working correctly. However, every time I send an email from Postfix it gets delivered. :)



Some methods:

  • Use @EightBitTony's approach
  • Use a VM for development and pull the virtual plug to the network
  • Use a firewall rule to drop outgoing packets for port 25.

and the best way:

| improve this answer | |
  • 1
    That is the best way to prevent delivery to a destination, yes. To prevent delivery in general, stop the smtp(8) daemon. – adaptr May 24 '12 at 9:55
  • @adaptr If you stop the smtp daemon who will add the emails to the queue of the smtp daemon ;-) – ndemou Sep 30 '16 at 16:49

I came across this other article before I ended up here.


Just defer emails to a particular transport, in this case SMTP:

pause delivery:

$ sudo postconf -e defer_transports=smtp; sudo postfix reload

un-pause delivery:

$ sudo postconf -e defer_transports=; sudo postfix reload; sudo postfix flush

Mail will queue but not send.

| improve this answer | |

Send it to a valid hostname in a domain you own, that you know doesn't run an smtp server. For example, if you own server.domain.example and you know it's not running an smtp server, send them mail to bob@server.domain.example.

Postfix will queue it while it tries to talk to the target smtp server.

This assumes you've not configured postfix to send all mail to another relay, but to deliver directly.

And I'm sure there's a better way, to tell postfix to pause delivery, but hey, there's strength in variation.

| improve this answer | |
  • The canonical way to prevent delivery is to stop the smtp(8) daemon by including the following in main.cf: master_service_disable = smtp – adaptr May 24 '12 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.