Thank you Jerry. We didn't design for the RRT case, indeed. Please open a JIRA and post there the explanations you wrote on the mailing list and submit a patch. We will take it from there.
https://issues.apache.org/jira/browse/JAMES On 07/05/2014 04:57 PM, Jerry Malcolm wrote: > Update.... > > I updated the ToSenderFolder mailet and got it to work properly with my > account that uses RecipientRewrite. > > I cloned some lines from the LocalDelivery mailet that sets up the rrt > variable via inject. In ToSenderFolder.doService(), I first call > rrt.getMappings(....) using the sender email address. If result != > null, I pull the username string from the result. If result=null, I > fall back to the existing code that uses the sender email as the username. > > Minimal testing so far. But it appears to be working correctly now. > > As I stated in my previous email, I think this is a bug in the mailet > and not a feature request. The mailet should handle by default the > situation where the sender email address is NOT the username, and not > require my custom hack to make it work. > > Thanks. > > Jerry > > > On 7/4/2014 8:30 PM, Jerry Malcolm wrote: >> I tried activating the ToSenderFolder mailet and could not get it to >> work. I added some debug code and looked through the source, and I >> see where the problem is. >> >> The mailet assumes that the username (user login name / repository >> name) is the sender's email address. (see code snippit at the bottom >> of this post). Where this 'could' be the case, and could be argued >> that it's that way in many situations, it's not required. My login id >> for my mail account is "m...@mycompany.net". I have several employees >> that share this one account. However, they send mail as >> j...@mycompany.net, b...@mycompany.net, and su...@mycompany.net. I use >> the virtual recipient rewrite function to map all of these ids to the >> m...@mycompany.net repository. >> >> The problem in the mailet is that it is trying to put sent mail in >> j...@mycompany.net/Sent, etc. which is not a valid repository. >> >> In order to fix this, I need to figure out the real username that was >> used to log in to SMTP. I suspect you're going to tell me that >> there's not a way in the world to get addressability to the real >> username inside a mailet, right...? I guess the next option would be >> to use the recipient rewrite table in the db to map the sender to the >> repository. I'll look around for a recipient rewrite mapping class >> that I can use. Or I guess I could just brute-force it directly with >> a SQL query to the table in the db. Either way, I should be able to >> determine the real repository name so the mailet can know where to put >> the Sent message. >> >> I believe there is a philosophical design problem currently in the >> mailet to assume the sender email address is the repository name. But >> since I need to go ahead and fix this, I'd like to know what the James >> team would suggest to be the 'right way' to implement the fix. >> >> Suggestions? >> >> Thx. >> >> Jerry >> ------------------------------------------------------ code snippit--> >> String username; >> try { >> if (usersRepository.supportVirtualHosting()) { >> username = sender.toString(); >> } >> else { >> username = sender.getLocalPart(); >> } >> } catch (UsersRepositoryException e) { >> throw new MessagingException(e.getMessage()); >> } >> >> >> >> >> ----- >> No virus found in this message. >> Checked by AVG - www.avg.com >> Version: 2014.0.4592 / Virus Database: 3986/7800 - Release Date: 07/04/14 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: server-user-unsubscr...@james.apache.org > For additional commands, e-mail: server-user-h...@james.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: server-user-unsubscr...@james.apache.org For additional commands, e-mail: server-user-h...@james.apache.org