Hi everyone, I am new with James and I am reading as much documentation (and even some source code) that I can. I was wondering if there was a complete behavior documentation about the RecipientRewriteTable. What I mean is that part of the documentation seems buggy and some parts of the implementation seems not enough flexible, while still being flexible in other ways.
Bassically, here are my use cases. I want: 1 - To have local accounts (no issue there) 2 - To be able to set redirections from one email to multiple emails 3 - To be able to sometime have a catchall email address ---[ 2 - To be able to set redirections from one email to multiple emails ]--- Starting with the documentation available here https://james.apache.org/server/manage-cli.html You can manage address mapping like (redirects email from u...@domain.tld to redirec...@domain.new, then deletes the mapping): {cli} AddAddressMapping redirected domain.new u...@domain.tld That means that to redirect u...@domain.tld -> redirec...@domain.new, we need to execute: {cli} AddAddressMapping redirected domain.new u...@domain.tld Which looks like the reverse to <- from and that looks fine when we look at the next one about Regex, which is {cli} AddRegexMapping redirected domain.new .*@domain.tld Trying from red...@foilen-lab.com to ad...@foilen-lab.com (a local account) ../bin/james-cli.sh -h 127.0.0.1 -p 9999 AddAddressMapping admin foilen-lab.com red...@foilen-lab.com ../bin/james-cli.sh -h 127.0.0.1 -p 9999 ListMappings ad...@foilen-lab.com=red...@foilen-lab.com That looks backward. Looking at the DB: INSERT INTO `JAMES_RECIPIENT_REWRITE` (`DOMAIN_NAME`, `USER_NAME`, `TARGET_ADDRESS`) VALUES ('foilen-lab.com','admin','red...@foilen-lab.com'); It would mean that the target is the alias for the redirection and it goes to USER_NAME+DOMAIN_NAME, which could be fine, but since the primary key is: PRIMARY KEY (`DOMAIN_NAME`,`USER_NAME`) That implies that a destination can be used only once. E.g: I cannot have red...@foilen-lab.com and red...@foilen-lab.com both going to ad...@foilen-lab.com , which makes no sense. Then, looking at the logs when sending an email to red...@foilen-lab.com: Rejected message. Unknown user: red...@foilen-lab.com Looks like the redirection is being ignored. --------------------- Now, trying it the other way around: ../bin/james-cli.sh -h 127.0.0.1 -p 9999 RemoveAddressMapping admin foilen-lab.com red...@foilen-lab.com ../bin/james-cli.sh -h 127.0.0.1 -p 9999 AddAddressMapping redir1 foilen-lab.com ad...@foilen-lab.com Sending an email to red...@foilen-lab.com now goes to my ad...@foilen-lab.com local account. [FIX 1] So, the documentation needs to be fixed. Then, due to the primary key, that means that I cannot put one source to multiple targets. Is that a "per design" limitation or a "bug"? I could understand it as a "per design" limitation, but considering it is possible to have: - red...@foilen-lab.com -> ad...@foilen-lab.com - redir.*@foilen-lab.com -> another_u...@foilen-lab.com Due to the regexp, both matches, so what is the expected behavior? (is it sending to both, to one randomly or to one with a special logic?) ---[ 3- To be able to sometime have a catchall email address ]--- In the interface RecipientRewriteTable, I see there is a WILDCARD = "*" which could make me happy. I haven't tested it yet and I am wondering the behavior. My expected behavior would be, for a specific email address: - If there is a rewrite, do it - Else if there is a local account, use it - Else if there is a wildcard for the domain, use it - Else, don't care since it will eventually go to "local-address-error" Is that the actual behavior? Due to the "regexp" feature which could have some rewrites like: - .*@foilen-lab.com -> ad...@foilen-lab.com that would be a catchall while also permit being matched by other regexp, I really don't know where that is going. thanks