Mutt as an command line ImapFilter

I have a free email account on server and I use it as a secondary account only for shopping or registration purposes. Everything works just fine and the only issue is the SPAM which sends me everyday and this SPAM can not be filtered by the filters defined in the account settings. I am fine with this since I am not paying for anything and it looks like it’s just the price you need to pay for this account.

I have started to look for some command line tool in order to filter and remove these unwanted and annoying messages automatically. I found a tool named ImapFilter. You can define some rules how to deal with the messages and ImapFilter will do everything by itself. The configuration is pretty simple:
Screenshot from 2018-09-10 16-20-29

… however in my case I was not able to make it running, I was playing around with the settings but every time I was receiving an error like that:

$ imapfilter
imapfilter: reading data through SSL; EOF in violation of the protocol

So I decided to look for an alternative solution and eventually I found a command line email client Mutt. It’s really powerful and handy utility and without any issues I was able to make it running and apply SPAM filtering.

The configuration is stored in ~/.muttrc file:

set imap_user = ""
set imap_pass = "somepassword"
set smtp_url = "smtps://"
set smtp_pass = "somepassword"
set from = ""
set realname = "AA"
set folder = "imaps://"
set spoolfile = "+INBOX"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.cache/mutt/messages
set certificate_file=~/.mutt/certificates
set move = no

To show the messages in Mutt sent by one need to define the limit ~f Then to delete the messages one need to press D and confirm the operation with the key $. And that’s it.

To make it even faster I defined an alias in ~/.bashrc file:

alias wppl='mutt -e "push '"'"'<limit>~f<enter>D<enter>'"'"'"'

which opens the mutt with already filtered and tagged to delete messages.


How to detach a process from the Terminal

There is a number of methods which allow you to run the process in the background detached from the terminal, e.g. tmux, nohup, screen. However recently I have started using the most basic unix method I have just forgotten for many years, I mean the combination of bg and disown.
I will use my everyday scenario, I usually start my eclipse from the terminal:

$ ./eclipse

Sometimes I forget to add & at the end but there is a way how to place it to the background and detach from the terminal. You need to press CTRL+Z to suspend the process then list the jobs by typing

$ jobs

to receive the job number, e.g.:

[1]+  Stopped                 /home/runner/work/eclipse

next you need to move eclipse (job 1) to the background:

$ bg %1

and detach it from the terminal:

disown %1

when you close the terminal the eclipse will be still working.

Bash: tmux script

In one of my development scenarios I need to login to 3 different remote machines and execute there some commands. To make it more simple I wrote the bash script which invokes tmux to split the terminal window into 3 pieces:

tmux new-session -d 'ssh foo@bar'
tmux split-window -h 'ssh -t foo@bar2 "cd foo/bar && exec bash -l"'
tmux split-window -v 'ssh foo@bar3'
tmux resize-pane -D 10
tmux attach-session -d