20090408

Forward mappings

The presented configuration allows to gather messages of specified address pattern inside the given mail account.
The below example is based on the destination address, but can be easily changed into source based.

Sun Java Messaging Server allow to use the FORWARD mapping table and FORWARD lookup table.
I will focus on FORWARD Mapping Table. This usage is disabled by default. So, before I can go further I have to enable the USE_FORWARD_DATABASE withing the option.dat file.

USE_FORWARD_DATABASE can take one of three values. The meaning is as follows:

  • 1 - use forward database
  • 8 - use forward database entries with a specified channel
  • 16 - use forward mapping table entries with a specified channel

To get the pieces together I've used 16, so:

[option.dat]
[...]
USE_FORWARD_DATABASE=16

To let the Messaging Server keep all the messages begining with a prefix- on the wisnios@wisnios.com account, add the following to your mappings file:

FORWARD

!
! Format for channel specific forward mapping entries
! src-channel|source-address|original-address changed-address
!
*|*|prefix-*@wisnios.com $D$H$Ywisnios@wisnios.com


The first * (asterisk) could be tcp_local. I thought so, but it's not true.
Simple test with imsimta test -rewrite -debug prefix-test@wisnios.com shows that message uses the l channel:

[...]
12:41:14.65: Applying forward mapping to: l|postmaster@book.entic.net|prefix-test@wisnios.com
12:41:14.65: Matched, result is: wisnios@wisnios.com
[...]

The second field could be used as an additional pattern filter, based on the sender address / domain part.
In my example it's also the asterisk sign.

The third field does the trick.

$D - run rewrite process one more time (without this option mapping will fail)
$H - do not check any other forward lookup table or FORWARD mapping entries (optional with this one entry)
$Y - use specified address as a new one (no comment - required)

So, let's try:

book [/]# imsimta test -mapping -debug
Enter table name: FORWARD
Input string: tcp_local|wisnios@gmail.com|prefix-test@wisnios.com
13:00:03.39: Mapping 6 applied to tcp_local|wisnios@gmail.com|prefix-test@wisnios.com
13:00:03.39: Entry #1 matched, pattern "*|*|prefix-*@wisnios.com", template "$D$H$Ywisnios@wisnios.com", match #0.
13:00:03.39: New target "wisnios@wisnios.com"
13:00:03.39: Exiting...
13:00:03.39: Final result "wisnios@wisnios.com"
Output string: wisnios@wisnios.com
Output flags: [0, 'D' (68), 'H' (72), 'Y' (89)]
Input string:

The last bastion was the imsimta command itself.
After the configuration changes I've run imsimta cnbuild && imsimta reload.
That was a mistake.
It allows imsimta test -rewrite complete successfully, but rejects the incoming messages to prefix-something with:
550 5.1.1 unknown or illegal alias: prefix-something@wisnios.com

To make everything work smoothly run imsimta restart after job complete.

To test this configuration I've used:

Sun Java(tm) System Messaging Server 6.3-2.01 (built Jun 13 2007; 64bit)
libimta.so 6.3-2.01 (built 00:30:08, Jun 13 2007; 64bit)

No comments: