Difference between revisions of "Configuring Postfix to work with piped scripts"

Line 1: Line 1:
{{Archive}}{{Unsupported}}
+
{{Unsupported}}
  
 
== Background ==
 
== Background ==
  
Many users of Zimbra may want to integrate Request Tracker (RT) or Mailman, both of which are typically configured by executing scripts from /etc/aliases.  With Zimbra 5, /etc/aliases appears to be mostly ignored and therefore cannot be used.  This wiki entry is based on a trick that was figured out in [http://www.zimbra.com/forums/installation/2859-aliases-scripts.html this forum post.]
+
Many users of Zimbra may want to integrate Request Tracker (RT) or Mailman, both of which are typically configured by executing scripts from /etc/aliases
 +
 
 +
Note that Mailman has a [ZCS_Mailman_Integration much easier way to integrate] using a dedicated subdomain.
 +
 
 +
== Zimbra 8.6.x and newer method ==
 +
 
 +
This is confirmed working on 8.6.x, and likely will work on 8.7
 +
 
 +
'''0. Make sure you're user Zimbra'''
 +
$ su - zimbra
 +
 
 +
'''1. Configure the Postfix main.cf to handle an additional transport map'''
 +
Execute the following command:
 +
 
 +
zmlocalconfig -e postfix_transport_maps=' hash:/opt/zimbra/postfix/conf/transport,ldap:/opt/zimbra/conf/ldap-transport.cf'
 +
 
 +
This will add /opt/zimbra/postfix/conf/transport as an additional transport map.
 +
 
 +
Note, if you have done this already for Mailman integration or other reasons, you can ignore this as it's already done.
 +
 
 +
''2.  Define the pipe transports'''
 +
 
 +
The transport definitions 'rt-pipe' and 'rt-comment-pipe' must now be definedEdit /opt/zimbra/postfix/conf/master.cf'''.in''' and add the following lines to the end of the file:
 +
 
 +
rt-pipe        unix    -      n              n              -              -      pipe
 +
        flags= user=www-data argv=/opt/rt4/bin/rt-mailgate --queue general --action correspond --url http://rt.fasma.org/
 +
rt-comment-pipe        unix    -      n              n              -              -      pipe
 +
        flags= user=www-data argv=/opt/rt4/bin/rt-mailgate --queue general --action comment --url http://rt.fasma.org/
 +
 
 +
Note that the 2nd line needs to be right under the first and must start with whitespace, and the first line cannot start with whitespace or postfix will fail with 'unexpected command-line argument' errors. Also make sure the user= line is pointing to a valid user with permissions to execute the script.  This user must not be the postfix or root user or the pipe will fail.
 +
 
 +
''3. Point a user at your transport pipe'''
 +
zmprov ca rt@fasma.org ''
 +
zmprov ma rt@fasma.org zimbraMailTransport rt-pipe:
 +
 
 +
zmprov ca rt-comment@fasma.org ''
 +
zmprov ma rt-comment@fasma.org zimbraMailTransport rt-comment-pipe:
 +
 
 +
This could be done via the GUI as well, but it's easier from the CLI to get right.  These users will show up in the management interface too.
 +
 
 +
'''4.  Restart Postfix and test'''
 +
 
 +
Execute the following commands:
 +
 
 +
zmmtactl stop ; zmmtactl start
 +
 
 +
Now, you should be able to email rt@example.com and receive a message back.  Tail /var/log/zimbra.log to watch for errors.
 +
 
 +
 
 +
== Old way for Zimbra 5 and 6 ==
 +
 
 +
With Zimbra 5, /etc/aliases appears to be mostly ignored and therefore cannot be used.  This wiki entry is based on a trick that was figured out in [http://www.zimbra.com/forums/installation/2859-aliases-scripts.html this forum post.]
  
 
This wiki entry is also confirmed to work for ZCS 6.x.
 
This wiki entry is also confirmed to work for ZCS 6.x.
  
== Steps for integrating RT ==
+
=== Steps for integrating RT ===
 
'''0. Make sure you're user Zimbra'''
 
'''0. Make sure you're user Zimbra'''
 
  $ su - zimbra
 
  $ su - zimbra

Revision as of 19:49, 17 August 2017


Background

Many users of Zimbra may want to integrate Request Tracker (RT) or Mailman, both of which are typically configured by executing scripts from /etc/aliases.

Note that Mailman has a [ZCS_Mailman_Integration much easier way to integrate] using a dedicated subdomain.

Zimbra 8.6.x and newer method

This is confirmed working on 8.6.x, and likely will work on 8.7

0. Make sure you're user Zimbra

$ su - zimbra

1. Configure the Postfix main.cf to handle an additional transport map Execute the following command:

zmlocalconfig -e postfix_transport_maps=' hash:/opt/zimbra/postfix/conf/transport,ldap:/opt/zimbra/conf/ldap-transport.cf'

This will add /opt/zimbra/postfix/conf/transport as an additional transport map.

Note, if you have done this already for Mailman integration or other reasons, you can ignore this as it's already done.

2. Define the pipe transports'

The transport definitions 'rt-pipe' and 'rt-comment-pipe' must now be defined. Edit /opt/zimbra/postfix/conf/master.cf.in and add the following lines to the end of the file:

rt-pipe         unix    -       n               n               -               -       pipe
       flags= user=www-data argv=/opt/rt4/bin/rt-mailgate --queue general --action correspond --url http://rt.fasma.org/

rt-comment-pipe unix - n n - - pipe

       flags= user=www-data argv=/opt/rt4/bin/rt-mailgate --queue general --action comment --url http://rt.fasma.org/

Note that the 2nd line needs to be right under the first and must start with whitespace, and the first line cannot start with whitespace or postfix will fail with 'unexpected command-line argument' errors. Also make sure the user= line is pointing to a valid user with permissions to execute the script. This user must not be the postfix or root user or the pipe will fail.

3. Point a user at your transport pipe' zmprov ca rt@fasma.org zmprov ma rt@fasma.org zimbraMailTransport rt-pipe:

zmprov ca rt-comment@fasma.org zmprov ma rt-comment@fasma.org zimbraMailTransport rt-comment-pipe:

This could be done via the GUI as well, but it's easier from the CLI to get right. These users will show up in the management interface too.

4. Restart Postfix and test

Execute the following commands:

zmmtactl stop ; zmmtactl start

Now, you should be able to email rt@example.com and receive a message back. Tail /var/log/zimbra.log to watch for errors.


Old way for Zimbra 5 and 6

With Zimbra 5, /etc/aliases appears to be mostly ignored and therefore cannot be used. This wiki entry is based on a trick that was figured out in this forum post.

This wiki entry is also confirmed to work for ZCS 6.x.

Steps for integrating RT

0. Make sure you're user Zimbra

$ su - zimbra
# su - zimbra

In the first case you may have permissions problems; in the second, your $PATH will be suboptimal.

1. Configure the Postfix main.cf to handle an additional transport map Execute the following command:

zmlocalconfig -e postfix_transport_maps=' hash:/opt/zimbra/postfix/conf/transport,ldap:/opt/zimbra/conf/ldap-transport.cf'

This will add /opt/zimbra/postfix/conf/transport as an additional transport map.


2. Create the transport map

Edit /opt/zimbra/postfix/conf/transport and place the following lines at the top:

# Pipe transports for RT queues
# YOU HAVE TO ADD THE PIPES TO /opt/zimbra/postfix/conf/master.cf if you want them to work!!!
rt@example.com     rt-pipe
rt-comment@example.com     rt-comment-pipe


And then create the transport db by executing (as zimbra)

postmap /opt/zimbra/postfix/conf/transport


3. Define the pipe transports

The transport definitions 'rt-pipe' and 'rt-comment-pipe' must now be defined. Edit /opt/zimbra/postfix/conf/master.cf.in and add the following lines to the end of the file:

rt-pipe         unix    -       n               n               -               -       pipe
    flags= user=www argv=/opt/rt3/bin/rt-mailgate --queue general --action correspond --url http://rt.example.com/
rt-comment-pipe         unix    -       n               n               -               -       pipe
    flags= user=www argv=/opt/rt3/bin/rt-mailgate --queue general --action comment --url https://rt.example.com/

Note that the 2nd line needs to be right under the first and must start with whitespace, and the first line cannot start with whitespace or postfix will fail with 'unexpected command-line argument' errors. Also make sure the user= line is pointing to a valid user with permissions to execute the script. This user must not be the postfix or root user or the pipe will fail.


4. Restart Postfix and test

Execute the following commands:

zmmtactl stop ; zmmtactl start

Now, you should be able to email rt@example.com and receive a message back. grep for RT in /var/log/messages as well as tail /var/log/mail to watch for errors.


Verified Against: Unknown Date Created: 8/1/2008
Article ID: https://wiki.zimbra.com/index.php?title=Configuring_Postfix_to_work_with_piped_scripts Date Modified: 2017-08-17



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search