From LedHed's Wiki
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 33: Line 33:
 
  password = ********
 
  password = ********
 
  hosts = localhost
 
  hosts = localhost
  dbname = postfix
+
  dbname = mail
 
  query = SELECT transport FROM transport_table WHERE domain='%s'
 
  query = SELECT transport FROM transport_table WHERE domain='%s'
 
Edit main.cf and add/change:
 
Edit main.cf and add/change:
Line 47: Line 47:
 
Create 'transport' field varchr(255)
 
Create 'transport' field varchr(255)
  
Add your FQDN in the 'domain' field and 'virtual:' in the 'transport' field.
+
Add your FQDN in the 'domain' field and 'virtual:' in the 'transport' field.<br>
Add 'autoreply.yourdomain.com in the 'domain' field and 'vacation' in the 'transport' field.
+
Add 'autoreply.yourdomain.com in the 'domain' field and 'vacation' in the 'transport' field.<br>
 
it should look something like this:
 
it should look something like this:
 
  +----------------------+----------+
 
  +----------------------+----------+
Line 58: Line 58:
  
  
'''More to come'''
+
'''Overview'''<br>
 +
Postfix receives mail. It checks the transport_map for the appropriate transport for the recipients domain.
 +
What happens next is that the recipient has 2 aliases one to their mailbox and another to an autoreply.domain.
 +
The transport for the autoreply.domain is 'vacation' (located in master.cf) which pipes the message to vacation.pl which looks up a table in MySQL. This table contains a users vacation message. Vacation.pl then sends an email containing the recipients vacation message to the sender. Vacation.pl will only autoreply to each sender once.  The sender list is cached in MySQL.
 +
 
 +
To enable a vacation message, 2 pieces of information need to be set in MySQL.
 +
 
 +
1) Append [email protected] to the 'goto' field in the alias table.  The goto field is a comma seperated list of aliases.<br>
 +
Your alias table should look something like this:
 +
+-----------------+-------------------------------------------+------------+---------------------+---------------------+--------+
 +
| address        | goto                                      | domain    | created            | modified            | active |
 +
+-----------------+-------------------------------------------+------------+---------------------+---------------------+--------+
 +
| [email protected] | [email protected],[email protected] | domain.tld | 2005-11-09 13:45:00 | 2005-11-09 13:45:00 |      1 |
 +
+-----------------+-------------------------------------------+------------+---------------------+---------------------+--------+
 +
 
 +
2) Edit the vacation table, addind all relevant information. Do not add anything to the 'cache' field unless you do not want a vacation message sent to that user.<br>
 +
Your vacation table should look something like this:
 +
+-----------------+---------------------+------------------------------------+-------+------------+---------------------+--------+
 +
| email          | subject            | body                              | cache | domain    | created            | active |
 +
+-----------------+---------------------+------------------------------------+-------+------------+---------------------+--------+
 +
| [email protected] | User is on vacation | I will be on vacation from Jan 1-7 |      | domain.tld | 2005-11-09 13:45:00 |      1 |
 +
+-----------------+---------------------+------------------------------------+-------+------------+---------------------+--------+
 +
 
 +
 
 
[[Category:PostfixAdmin]]
 
[[Category:PostfixAdmin]]

Latest revision as of 17:30, 3 April 2007

Reference: http://linox.be/index.php/2005/07/13/44/#comment-52886

Creating the Vacation User/Group

groupadd vacation
useradd -s/sbin/nologin -d/nonexistent -g vacation vacation

See [User Management] for more information on creating users in linux


Creating Directories

mkdir -p /var/spool/vacation
cp /tmp/postfixadmin-2.1.0/VIRTUAL_VACATION/vacation.pl /var/spool/vacation
chown -R vacation.vacation /var/spool/vacation
chmod -R 700 /var/spool/vacation


Postfix Intigration

Master.cf

Edit /etc/postfix/master.cf Add these lines at the bottom.

### Postfix Admin Vacation Message
vacation  unix  -       n       n       -       -       pipe
  flags=Rhu user=vacation argv=/var/spool/vacation/vacation.pl

Transport Map

Create a transport map

touch /etc/postfix/transport_maps.cf

Edit transport_maps.cf and add these lines to it. Substitute your information where needed.

user = postfix
password = ********
hosts = localhost
dbname = mail
query = SELECT transport FROM transport_table WHERE domain='%s'

Edit main.cf and add/change:

transport_maps = mysql:/etc/postfix/transport_maps.cf


MySQL

Down and Dirty

Create a table called 'transport' Create 'domain' field varchar(255) and PKEY Create 'transport' field varchr(255)

Add your FQDN in the 'domain' field and 'virtual:' in the 'transport' field.
Add 'autoreply.yourdomain.com in the 'domain' field and 'vacation' in the 'transport' field.
it should look something like this:

+----------------------+----------+
| domain               | transport|
+----------------------+----------+
| domain.tld           | virtual: |
| autoreply.domain.tld | vacation |
+----------------------+----------+


Overview
Postfix receives mail. It checks the transport_map for the appropriate transport for the recipients domain. What happens next is that the recipient has 2 aliases one to their mailbox and another to an autoreply.domain. The transport for the autoreply.domain is 'vacation' (located in master.cf) which pipes the message to vacation.pl which looks up a table in MySQL. This table contains a users vacation message. Vacation.pl then sends an email containing the recipients vacation message to the sender. Vacation.pl will only autoreply to each sender once. The sender list is cached in MySQL.

To enable a vacation message, 2 pieces of information need to be set in MySQL.

1) Append [email protected] to the 'goto' field in the alias table. The goto field is a comma seperated list of aliases.
Your alias table should look something like this:

+-----------------+-------------------------------------------+------------+---------------------+---------------------+--------+
| address         | goto                                      | domain     | created             | modified            | active |
+-----------------+-------------------------------------------+------------+---------------------+---------------------+--------+
| [email protected] | [email protected],[email protected] | domain.tld | 2005-11-09 13:45:00 | 2005-11-09 13:45:00 |      1 |
+-----------------+-------------------------------------------+------------+---------------------+---------------------+--------+

2) Edit the vacation table, addind all relevant information. Do not add anything to the 'cache' field unless you do not want a vacation message sent to that user.
Your vacation table should look something like this:

+-----------------+---------------------+------------------------------------+-------+------------+---------------------+--------+
| email           | subject             | body                               | cache | domain     | created             | active |
+-----------------+---------------------+------------------------------------+-------+------------+---------------------+--------+
| [email protected] | User is on vacation | I will be on vacation from Jan 1-7 |       | domain.tld | 2005-11-09 13:45:00 |      1 |
+-----------------+---------------------+------------------------------------+-------+------------+---------------------+--------+