You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Jerry Malcolm <te...@malcolms.com> on 2019/10/24 05:48:51 UTC

Setting Message Flags in Mailet?

I have a mailet that needs to set the $label3 message flag in certain 
emails going through the pipeline prior to being stored in the 
repository.  In my mailet:

         mail.getMessage().setFlags(new Flags("$label3"), true);
         mail.getMessage().saveChanges();

But the flags are not being saved.  Messages with this flag will appear 
as a different color in Thunderbird.  I had a different way of setting 
flags in v3b5 which worked back then.  There is a parameter on 
mailbox.appendMessage(...) which is what my old ToFolder clone was 
using.   The new way in the ToSenderFolder, etc is to use 
MailBoxAppender.append(...) which does not include an option for 
including flags.  Hence my attempt at putting the flags in the message 
prior to writing to the mailbox.  But that doesn't seem to be working.

Should what I'm doing above work?  If not, is there another way to get 
flags to be stored along with messages?


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


Re: Setting Message Flags in Mailet? (Proposed Fix)

Posted by Tellier Benoit <bt...@apache.org>.
Looks great!

You are very welcome to propose a pull request regarding this.

Benoit

On 26/10/2019 10:19, Jerry Malcolm wrote:
> I have located the code that is apparently causing this problem. It's an
> easy fix, and it's now working for me.  But I would like to get
> verification from some more-seasoned JAMES developers to make sure I'm
> not violating any architectures.
> 
> Class: MailBoxAppender.java; Method: appendMessageToMailbox(.....)
> 
>         return mailbox.appendMessage(MessageManager.AppendCommand.builder()
>             .withFlags(mail.getFlags())
> <========================================== Add
>             .recent()
>             .build(new MimeMessageInputStream(mail)),
>             session);
> 
> If a mailet somewhere in the pipeline prior to the storing of the mail
> sets flags in the message as shown in my previous post below, the flags
> are extracted with the change above and sent to the AppendCommand
> builder to be included in the storing of the email.
> 
> After making this change, the flags are now correctly displaying as
> expected in Thunderbird.
> 
> If no one disagrees, I'll open a Jira and start the process to get this
> change into git.
> 
> Jerry
> 
> On 10/24/2019 12:48 AM, Jerry Malcolm wrote:
>> I have a mailet that needs to set the $label3 message flag in certain
>> emails going through the pipeline prior to being stored in the
>> repository.  In my mailet:
>>
>>         mail.getMessage().setFlags(new Flags("$label3"), true);
>>         mail.getMessage().saveChanges();
>>
>> But the flags are not being saved.  Messages with this flag will
>> appear as a different color in Thunderbird.  I had a different way of
>> setting flags in v3b5 which worked back then.  There is a parameter on
>> mailbox.appendMessage(...) which is what my old ToFolder clone was
>> using.   The new way in the ToSenderFolder, etc is to use
>> MailBoxAppender.append(...) which does not include an option for
>> including flags.  Hence my attempt at putting the flags in the message
>> prior to writing to the mailbox.  But that doesn't seem to be working.
>>
>> Should what I'm doing above work?  If not, is there another way to get
>> flags to be stored along with messages?
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-dev-help@james.apache.org
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
> 

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


Re: Setting Message Flags in Mailet? (Proposed Fix)

Posted by Jerry Malcolm <te...@malcolms.com>.
I have located the code that is apparently causing this problem. It's an 
easy fix, and it's now working for me.  But I would like to get 
verification from some more-seasoned JAMES developers to make sure I'm 
not violating any architectures.

Class: MailBoxAppender.java; Method: appendMessageToMailbox(.....)

         return mailbox.appendMessage(MessageManager.AppendCommand.builder()
             .withFlags(mail.getFlags()) 
<========================================== Add
             .recent()
             .build(new MimeMessageInputStream(mail)),
             session);

If a mailet somewhere in the pipeline prior to the storing of the mail 
sets flags in the message as shown in my previous post below, the flags 
are extracted with the change above and sent to the AppendCommand 
builder to be included in the storing of the email.

After making this change, the flags are now correctly displaying as 
expected in Thunderbird.

If no one disagrees, I'll open a Jira and start the process to get this 
change into git.

Jerry

On 10/24/2019 12:48 AM, Jerry Malcolm wrote:
> I have a mailet that needs to set the $label3 message flag in certain 
> emails going through the pipeline prior to being stored in the 
> repository.  In my mailet:
>
>         mail.getMessage().setFlags(new Flags("$label3"), true);
>         mail.getMessage().saveChanges();
>
> But the flags are not being saved.  Messages with this flag will 
> appear as a different color in Thunderbird.  I had a different way of 
> setting flags in v3b5 which worked back then.  There is a parameter on 
> mailbox.appendMessage(...) which is what my old ToFolder clone was 
> using.   The new way in the ToSenderFolder, etc is to use 
> MailBoxAppender.append(...) which does not include an option for 
> including flags.  Hence my attempt at putting the flags in the message 
> prior to writing to the mailbox.  But that doesn't seem to be working.
>
> Should what I'm doing above work?  If not, is there another way to get 
> flags to be stored along with messages?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>

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