#10 simple python vacation script



since the vacation.pl distributed with postfixadmin is broken, i rewrote the whole thing in python.


* loop detection
* Uses Sender:-Header if present
* rejects multiple Adresses in From:-Header, but replies to Sender: or Reply-To: if present
* Does not answer to Spam-Messages (checks for X-Spam-Status)
* Does not answer to Precedence: [bulk|list|junk]
* Does not send notifications to people that have been notified in the last week
* writes messages to logfile
* logs errors to errorlog, or if all else fails, tries to send a message to an administrator


* So far only support for Postgres, but changing this to MySQL should be as easy as changing two lines of code (line 20 and 40).
*relies on postfix handing in the recipients e-mail address, so you have to change master.cf like this:

vacation unix - n n - - pipe
flags=DRhu user=vacation argv=/var/spool/vacation/vacation.py ${user}

* based on the gentoo-wiki tablelayout, which I am not sure is the same as is propagated through postfixadmin (but I think it should):

Table "public.vacation"
Column | Type | Modifiers
email | character varying(255) | not null default ''::character varying
subject | character varying(255) | not null default ''::character varying
body | text | not null
cache | text |
domain | character varying(255) | not null default ''::character varying
created | timestamp with time zone | default now()
modified | timestamp with time zone | default now()
active | boolean | not null default true
"vacation_key" PRIMARY KEY, btree (email)

Table "public.vacation_notification"
Column | Type | Modifiers
on_vacation | character varying(255) | not null
notified | character varying(255) | not null
notified_at | timestamp with time zone | not null default now()
"vacation_notification_pkey" PRIMARY KEY, btree (on_vacation, notified)
Foreign-key constraints:
"vacation_notification_on_vacation_fkey" FOREIGN KEY (on_vacation) REFERENCES vacation(email) ON DELETE CASCADE

only limited testing has been done, friendly bug reports are welcome!


  • Thomas Witzenrath


  • GingerDog

    GingerDog - 2007-09-20

    Logged In: YES
    Originator: NO


    Thanks for taking the effort to write this. With this, and the PHP vacation script, I get the feeling that the vacation script(s) are quite useful.

    I'm not against merging this, but I don't want to maintain two code bases (hence vacation.pl has been replaced by vacation-pgsql.pl recently)... so either this has to be shown to be better than the perl vacation.pl and/or be shown to be more maintainable...

    Did you try the vacation-pgsql.pl script from subversion? (now just 'vacation.pl')

    Ideally "there can[should] be only one"....


  • Thomas Witzenrath

    Logged In: YES
    Originator: YES


    well, I have posted this to share it. I felt a rewrite of the (original) vacation script was needed, since there were many problems that I have encountered when using it. I fully understand that two (or more) versions of the same functionality can not be maintained.

    Personaly I think Python to be much more "maintainable", but thats just a personal thing, if you like Perl, keep the perl script and just ignore this.. I won't mind, since I can't promise I will maintain this thing in any way other than to keep it running for my customers.



  • GingerDog

    GingerDog - 2008-07-02

    Logged In: YES
    Originator: NO

    I should probably point out that your script is vulnerable to SQL injection (at least, I assume email addresses can contain ' marks).


Log in to post a comment.