Another PHP script for the autoreply transport in Postfix
The main idea behind this script was a functionality request. I have used
Postfix far over 6 years
so far. Within a Mail infrastructure I was called to build up we wanted to
give end users more flexibility within the platform. One of the needs (very
well taken) was the ability for users to set up their Out-of-office messages
in a really customizable fashion.
The script is a PHP script invoked directly by Postfix when invoked by the
autoreply transport. It currently implements the following features:
- MySQL Backend for message configuration and caching
- Messages are cached to avoid floodings between sender/receiver
- Custom messages set within a record corresponding each mailbox
- Active/Inactive flag for every box for quick activation (leaving custom message)
- Beginning and Ending time frame for autoreply messages
Currently the package does not include the class for the autoreply
management (I will try to build it up ASAP) but here comes the explanation for every
component.
Table autoreply_cache
This table holds the cache for the received messages. If a messages from a sender has been answered, a record is placed in this table. Until the cache expires no more autoreplies will be sent to same sender.
Table mailbox_users
This is actually a template (my table is a bit bigger, I narrowed it down as a proof concept for installation). Assume you have data stored in a table like this one. If your structure differs from this one, you will need to adapt SQL statement in the script at row 40 to match your very own configuration. mailbox_username is the only column relevant. It should contain the recipient e-mail address. The flag_active field of this table is not used.
Table autoreply_outofoffce
This is the core table. The ID_mailbox column is used as a foreign key to avoid spurious data in the database (and outofoffice cleanup in case a mailbox is deleted). The date_begin and date_end fields determines the time-frame the autoreply script will serve answers to the end-user. If the system's current time is not within the timeframe, the autoreply script exits with a 0 status code. The flag_active field (TRUE/FALSE) activates/deactivates the autoreply script. It is AND-ed with the time-frame. Finally the message_body field contains the autoreply message (actually text/only messages).





