Discussions of development and use of the Sup email client
 help / color / mirror / Atom feed
From: Robert Winkler <robert.winkler.mail@gmail.com>
To: The Sup email client <supmua@googlegroups.com>
Subject: Re: [sup] SpamAssassin (Spam/Ham) support for Sup
Date: Fri, 24 Jul 2020 03:38:27 -0700 (PDT)	[thread overview]
Message-ID: <4b899a9b-6df8-4a03-95f2-368a604ed294o@googlegroups.com> (raw)
In-Reply-To: <a2e8101d-3a3d-436f-88d3-158a7fd1a5fdo@googlegroups.com>


[-- Attachment #1.1: Type: text/plain, Size: 4861 bytes --]

Correction: The :unread label of spam mails has to be removed after 
copyingl. Why? If you remove :unread, the mail file is moved from the /new 
directory and not found any more. My working function looks like this:

class Redwood::InboxMode
  def label_spamassassin_spam
    thread = cursor_thread or return
    spamassassin_maildir_path = "/home/rob/Maildir/SpamAssassin/Spam/cur/"
    message_file = File.join(
      thread.latest_message.source.file_path,
      thread.latest_message.source_info.to_s)
    FileUtils.cp(message_file, spamassassin_maildir_path)
    BufferManager.flash "Copied to SpamAssassin Spam file: #{File.basename 
message_file}"
    toggle_spam
    thread.remove_label :unread
    flush_index
  end
end


Best, Robert


On Friday, 10 July 2020 16:58:16 UTC-5, Robert Winkler wrote:
>
> Thanks for all the useful code, Iain.
>
> Here the final solution. Explication: Spam (= 'undesired') messages and 
> Ham (= 'desired') messages are copied into separate Maildir folders. 
> Those are synchronized with an IMAP server (using OfflineImap) for 
> training a SpamAssassin filter (running daily on a server, using CRON):
> The last message of a thread is chosen by 's' (Spam) or 'h' (Ham) in the 
> Inbox or Search Results Mode (e.g. in the display of unread messages).
> Spam messages are removed from the Inbox listing. Ham messages get a label 
> 'ham' which indicates that the message was already sent to training.
> The SpamAssassin folders are not observed by sup. Mails older than 5 days 
> are automatically deleted by (email and password are different, of course):
>
> archive-mails.sh
> echo 'cleaning Spam/Ham folders'
> archivemail -d 5 --delete imaps://"spamass@bioprocess.org
> ":"email-terminator2020!"@imap.ionos.de/Spam
> archivemail -d 5 --delete imaps://"spamass@bioprocess.org
> ":"email-terminator2020!"@imap.ionos.de/Ham
>
> keybindings.rb
> modes["inbox-mode"].keymap.add :label_spamassassin_spam, "Label as 
> SpamAssassin Spam", 's'
> modes["inbox-mode"].keymap.add :label_spamassassin_ham, "Label as 
> SpamAssassin Ham", 'h'
> modes["search-results-mode"].keymap.add :label_spamassassin_spam, "Label 
> as SpamAssassin Spam", 's'
> modes["search-results-mode"].keymap.add :label_spamassassin_ham, "Label 
> as SpamAssassin Ham", 'h'
>
> startup.rb
> class Redwood::InboxMode
>   def label_spamassassin_spam
>     thread = cursor_thread or return
>     spamassassin_maildir_path = "/home/rob/Maildir/SpamAssassin/Spam/cur/"
>     message_file = File.join(
>       thread.latest_message.source.file_path,
>       thread.latest_message.source_info.to_s)
>     toggle_spam
>     FileUtils.cp(message_file, spamassassin_maildir_path)
>     BufferManager.flash "Copied to SpamAssassin Spam file: 
> #{File.basename message_file}"
>   end
> end
>
> class Redwood::InboxMode
>   def label_spamassassin_ham
>  thread = cursor_thread or return
>  spamassassin_maildir_path = "/home/rob/Maildir/SpamAssassin/Ham/cur/"
>  message_file = File.join(
>  thread.latest_message.source.file_path,
>  thread.latest_message.source_info.to_s)
>  thread.apply_label :ham
>  FileUtils.cp(message_file, spamassassin_maildir_path)
>     BufferManager.flash "Copied to SpamAssassin Ham file: #{File.basename 
> message_file}"
>   end
> end
>
> class Redwood::SearchResultsMode
>   def label_spamassassin_spam
>     thread = cursor_thread or return
>     spamassassin_maildir_path = "/home/rob/Maildir/SpamAssassin/Spam/cur/"
>     message_file = File.join(
>       thread.latest_message.source.file_path,
>       thread.latest_message.source_info.to_s)
>     toggle_spam
>     FileUtils.cp(message_file, spamassassin_maildir_path)
>     BufferManager.flash "Copied to SpamAssassin Spam file: 
> #{File.basename message_file}"
>   end
> end
>
> class Redwood::SearchResultsMode
>   def label_spamassassin_ham
>  thread = cursor_thread or return
>  spamassassin_maildir_path = "/home/rob/Maildir/SpamAssassin/Ham/cur/"
>  message_file = File.join(
>  thread.latest_message.source.file_path,
>  thread.latest_message.source_info.to_s)
>  thread.apply_label :ham
>  FileUtils.cp(message_file, spamassassin_maildir_path)
>     BufferManager.flash "Copied to SpamAssassin Ham file: #{File.basename 
> message_file}"
>   end
> end
>
> note: The source_info needed a conversion to string: .to_s
>
> Thanks a lot again; sup is really mighty!
>
> Best regards, 
>
> Robert 
>
>
> On Friday, 10 July 2020 15:29:19 UTC-5, Iain Parris wrote:
>>
>> Excerpts from Iain Parris's message of 2020-07-10 21:26:12 +0100: 
>> > Assuming your source is also another Maildir, then we can find the full 
>> > path for the original message file. Then we can do a direct file copy 
>> of 
>> > this file into your SpamAssassin Spam Maildir. 
>>
>> I should add: in this demo, we copy only the *latest* message in the 
>> thread. 
>>
>> Kind regards, 
>> Iain 
>>
>

[-- Attachment #1.2: Type: text/html, Size: 22299 bytes --]

      parent reply	other threads:[~2020-07-24 10:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 18:36 Robert Winkler
2020-07-06 23:27 ` [sup] " Iain Parris
2020-07-08 17:06   ` Robert Winkler
2020-07-08 18:53     ` Iain Parris
2020-07-09 22:20       ` Robert Winkler
2020-07-10 20:26         ` Iain Parris
2020-07-10 20:29           ` Iain Parris
2020-07-10 21:58             ` Robert Winkler
2020-07-11 13:48               ` Iain Parris
2020-07-24 10:38               ` Robert Winkler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4b899a9b-6df8-4a03-95f2-368a604ed294o@googlegroups.com \
    --to=robert.winkler.mail@gmail.com \
    --cc=supmua@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox