Hide a message?

Cameron Simpson cs at cskk.id.au
Sat Dec 15 08:35:12 UTC 2018


On 15Dec2018 17:01, Erik Christiansen <dvalin at internode.on.net> wrote:
>On 13.12.18 13:05, Kurt Hackenberg wrote:
>> You may want to preserve message attributes -- things like, this 
>> message has
>> been read, this message has been replied to, this message has been flagged,
>> this message has been assigned the keyword "blorgh". Mail delivery agents,
>> including procmail, are likely to drop that information.
>
>Hmmm ... can any of that actually be true? Let's check. Mutt makes flag
>and read status persistent through added headers such as:
>
>Status: RO
>X-Status: F
>
>Is it in reality even remotely "likely" that any LDA contains code to
>search out those headers and delete them in transit? (Please feel free
>to post any code snippets found.)
>
>The assertion also seems to ignore that mutt inserts those headers
>_after_ the LDA has delivered the messages, so there is normally no
>possible opportunity for the claimed LDA header removal - is there?

If you use a tool which isn't mutt, yes there's some scope to lose this 
information. For example, in a mbox the Status: and/or X-Status: headers 
hold flags. In a Maildir the flags are stored in the message filename, 
not the headers (they may get _duplicated_ there).

As an example, my mail filing programme can save to mbox or Maildir and 
has this function:

    def save_to_folderpath(folderpath, M, message_path, flags):
      ''' Save the Message `M` to the resolved `folderpath`.
          `message_path`: pathname of existing message file, allowing
            hardlinking to new maildir if not None
          `flags`: save flags as from MessageFiler.flags
      '''
      if not os.path.exists(folderpath):
        make_maildir(folderpath)
      if ismaildir(folderpath):
        # save to Maildir
        mdir = Maildir(folderpath)
        maildir_flags = ''
        if flags.draft:   maildir_flags += 'D'
        if flags.flagged: maildir_flags += 'F'
        if flags.passed:  maildir_flags += 'P'
        if flags.replied: maildir_flags += 'R'
        if flags.seen:    maildir_flags += 'S'
        if flags.trashed: maildir_flags += 'T'
        if message_path is None:
          savekey = mdir.save_message(M, flags=maildir_flags)
        else:
          savekey = mdir.save_filepath(message_path, flags=maildir_flags)
        savepath = mdir.keypath(savekey)
        info("    OK %s" % (shortpath(savepath)))
        if message_path is None:
          # update saved message for hard linking
          message_path = savepath
      else:
        # save to mbox
        status = ''
        x_status = ''
        if flags.draft:   x_status += 'D'
        if flags.flagged: x_status += 'F'
        if flags.replied: status += 'R'
        if flags.passed:  x_status += 'P'
        if flags.seen:    x_status += 'S'
        if flags.trashed: x_status += 'T'
        if len(status) > 0:
          M['Status'] = status
        if len(x_status) > 0:
          M['X-Status'] = x_status
        with LogExceptions():
          text = M.as_string(True).replace('\nFrom ', '\n>From ')
        with open(folderpath, "a") as mboxfp:
          mboxfp.write(text)
        info("    OK >> %s" % (shortpath(folderpath)))
      return message_path

So when I wrote this, the mbox flags are _split_ over the Status: and 
the X-Status: headers. Yay.

If you use mutt to do the conversion, I'd expect flags to survive. I 
would not normally have any specific confidence that another tool would 
do so.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Mutt-users mailing list