You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Jerry Malcolm <te...@malcolms.com> on 2014/07/05 03:30:54 UTC

ToSenderFolder Mailet Failure (James 3)

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 "mail@myCompany.net". I have several employees that share 
this one account.  However, they send mail as Joe@myCompany.net, 
Bob@myCompany.net, and Susie@myCompany.net.  I use the virtual recipient 
rewrite function to map all of these ids to the mail@myCompany.net 
repository.

The problem in the mailet is that it is trying to put sent mail in 
Joe@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());
         }


Re: ToSenderFolder Mailet Failure (James 3)

Posted by Eric Charles <er...@apache.org>.
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 "mail@myCompany.net". I have several employees
>> that share this one account.  However, they send mail as
>> Joe@myCompany.net, Bob@myCompany.net, and Susie@myCompany.net.  I use
>> the virtual recipient rewrite function to map all of these ids to the
>> mail@myCompany.net repository.
>>
>> The problem in the mailet is that it is trying to put sent mail in
>> Joe@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-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: ToSenderFolder Mailet Failure (James 3)

Posted by Jerry Malcolm <te...@malcolms.com>.
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 "mail@myCompany.net". I have several employees 
> that share this one account.  However, they send mail as 
> Joe@myCompany.net, Bob@myCompany.net, and Susie@myCompany.net.  I use 
> the virtual recipient rewrite function to map all of these ids to the 
> mail@myCompany.net repository.
>
> The problem in the mailet is that it is trying to put sent mail in 
> Joe@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-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org