ConfigEximFromRTDB

From Request Tracker Wiki
Jump to navigation Jump to search

Due to the time required to create new Queues and the fact that this is managed by more then 1 person, I created a workaround to automate the creation of new RT Queues in Exim.

Note:

  • You need exim4.x with database support compiled in (4.5x probably supports Oracle and Interbase too, while older versions may only support mysql and pg). With debian, select exim4-daemon-heavy as the package to install.
  • All queues must have valid defined email addresses (localpart + domain)
  • Multiple queues with the same defined email address will cause a problem. (Though multiple queues using the same default email address will not)
  • There should probably be some mysql escaping in here to prevent SQL injection.

For exim4.x and RT2.x put this in your exim router configuration:

rt_correspond:
  driver = redirect
  condition = ${lookup mysql{select 1 from Queues where CorrespondAddress \
              like '$local_part@$domain' and Disabled = 0}{$value}fail}
  debug_print = local_part@$domain
  user = nobody
  data = "|/home/rt2/bin/rt-mailgate --queue \"${lookup mysql{select name \
         from Queues where CorrespondAddress like '$local_part@$domain' \
         and Disabled = 0}{$value}{rt}}\" --action correspond"
  pipe_transport = address_pipe

rt_comment:
  driver = redirect
  condition = ${lookup mysql{select 1 from Queues where CommentAddress \
              like '$local_part@$domain' and Disabled = 0}{$value}fail}
  user = nobody
  data = "|/home/rt2/bin/rt-mailgate --queue \"${lookup mysql{select \
          name from Queues where CommentAddress like '$local_part@$domain' \
          and Disabled = 0}{$value}{rt}}\" --action comment"
  pipe_transport = address_pipe

And for RT3:

rt_correspond:
  driver = redirect
  condition = ${lookup mysql{select 1 from rtdb.Queues where CorrespondAddress \
              like '$local_part@$domain' and Disabled = 0}{$value}fail}
  debug_print = local_part@$domain
  user = nobody
  data = "|/usr/bin/rt-mailgate --queue \"${lookup mysql{select name \
         from rtdb.Queues where CorrespondAddress like '$local_part@$domain' \
         and Disabled = 0}{$value}{rt}}\" --action correspond --url http://url.to/rt/"
  pipe_transport = address_pipe

rt_comment:
  driver = redirect
  condition = ${lookup mysql{select 1 from rtdb.Queues where CommentAddress \
              like '$local_part@$domain' and Disabled = 0}{$value}fail}
  user = nobody
  data = "|/usr/bin/rt-mailgate --queue \"${lookup mysql{select \
          name from rtdb.Queues where CommentAddress like '$local_part@$domain' \
          and Disabled = 0}{$value}{rt}}\" --action comment --url http://url.to/rt/"
  pipe_transport = address_pipe

Also add a

mysql_servers = localhost/rtdb/exim/<password>

line near the top of exim.conf to specify the mysql server host/db/user details.

Of course, if you aren't using mysql, you have to change the lookup stuff.

You may need to grant the user exim is using to log into mysql rights to your Queues table, e.g.:

GRANT SELECT (`id` , `Name` , `CorrespondAddress` , `CommentAddress` , `Disabled`) ON `rtdb`.`Queues` TO 'exim'@'localhost';