Lumail - The console email client


Training Spam Messages

SPAM is pretty much a matter of fact for email users these days, so being able to train messages as junk is useful.

Many users deploy custom solutions, be they spamassassin, crm114, or something different.

In general though there are two ways to train a mis-filed message as SPAM:

Training via piping

Here we execute the command "~/bin/train-spam" with the path to the message we're viewing, or under the point.

function train_spam()
   local msg = Message.at_point()
   if ( msg == nil ) then
      Panel:append( "Failed to find message to train" )
      return
   end

   -- Get the path & execute the command
   local path = msg:path()
   os.execute("~/bin/train-spam " .. path )

   -- Delete the original now.
   Message.delete()
end

keymap['index']['X']   = "train_spam()"
keymap['message']['X'] = "train_spam()"

Training via message-saving

Here we take the current message, or the one under the mark in index-mode, and save it to ~/Maildir/train-spam/.

function train_spam()
   local msg = Message.at_point()
   if ( msg == nil ) then
      Panel:append( "Failed to find message to train" )
      return
   end

   -- Get folder to save to
   local folder = Maildir.new( os.getenv("HOME" ) .. "/Maildir/train-spam/" )
   folder:save_message(msg)

   -- Delete the original now.
   Message.delete()
end

keymap['index']['X']   = "train_spam()"
keymap['message']['X'] = "train_spam()"