1

I have some monitoring scripts on a couple of servers checking stuff that's not too critical (but that I indeed would like to receive email alerts for).

I use Postfix and my SMTP-to-SMS email address so that I can receive these notification on my cell phone. My problem is: I don't want to receive these alerts at dawn when I'm sleeping :(

I know I could modify my scripts in order to accomplish this but I decided that the best way to do this is to change postfix (since it isn't being used for anything else). How can I make postfix "put on hold" all new "incoming" messages, let say from 11pm to 6am? And then later at 6am flush that queue?

Thanks, JFA

  • 1
    Well the obvious and most simple way would be to have cron do '/etc/init.d/postfix stop' at 11pm and '/etc/init.d/postfix start' at 6am. But there will be much better ways of doing it. If it's not critical, then why have it delivered to your cellphone in the first place - why not just have it sent to your email account. – WheresAlice Jan 13 '10 at 01:19
  • Hi. No...that won't work as my interface to the email system is via the /bin/mail command ...and if there is no MTA running it will fail. As I mentioned, I know I could change the timing thing on scripts but for other reasons I need to leave them like that ...and all messages generated at dawn should be indeed queued (but in "hold") until 6am that I want the MTA to flush them. There's got to be a way to put postfix in just-put-on-hold 'mode... –  Jan 13 '10 at 01:32
  • 6
    *That's* the best way you can think of? – womble Jan 13 '10 at 01:45

3 Answers3

6

Here's a crazy idea, but why don't you go ahead and change the notification? What is sending out the error?

Most monitoring systems allow you to specify the time span you want to be alerted during. I would work on it from that end, since disabling the mail daemon to stop a client from sending mail is backwards.

Change that which has the least effect.

Matt Simmons
  • 20,396
  • 10
  • 68
  • 116
1

Here is the reply I read on the postfix mailing list, from Wietse, the creator of postfix:

If you want to be really sure, use an access rule for new mail like:

header_checks=static:HOLD

and execute "postsuper -h ALL" for mail that is already in the queue. That freezes it in the queue.

What to do is to add this line at night time by a cron job in the main.cf file and reload postfix (postfix reload) afterwards. At day time delete or comment it and don't forget to free up all mails hold with something like postsuper -H ALL at the same time.

AndreKR
  • 551
  • 1
  • 3
  • 17
Gino
  • 11
  • 1
0

One of the nice things about postfix is that you can alter the running configuration and reload it pretty easily via the postconf -e and postfix reload commands

Otherwise, I'd suggest a cron script that blackhole routes your SMS gateway's IP address, which would force the system to queue until morning.

Greeblesnort
  • 1,759
  • 8
  • 10