Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
KMail to mutt with Maildir and procmail
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2452
Location: The Peanut Gallery

PostPosted: Sun Dec 23, 2012 11:24 pm    Post subject: KMail to mutt with Maildir and procmail Reply with quote

I've been a user of KDE for about 15 years or so, and have always loved KMail. I've always been used to waiting til at least X.2 or X.3 of KDE, but 4.Y was rough. Eventually even KMail succumbed to the madness that is semantic-craptop, requiring akonadi, nepomuk, virtuoso, redland.. strigi and best of all a full-blown production install of mysql-server just to let me know when an email arrived. I gave up, and had no email for months. I'd always wanted to try mutt, since I used to use pine (follow on to elm) at Uni (again a long time ago;) but I was wedded to a GUI. No other GUI client uses Maildir, which I've come to love, so eventually I bit the bullet and installed mutt, spent ages reading the wiki and realised that really I'd have to learn procmail as well.

Here's my current setup, based on original instructions at the Mutt wiki for getmail-3. I fetch from two accounts, one personal and one work related, and had Kmail filters set up to process incoming mail and redirect accordingly. I'm just writing up the basics of what I did and how it works first, and hopefully we can refine it over time.

This setup is for when you have more than one email account, and you want to setup filters, eg so that mailing-list things get put in the right folder. The end result is a setup of mutt to read and respond to email and news, with getmail used to fetch mail from within mutt. getmail delivers the mail via procmail, which does any filtering required. If you just have one account, I'd still recommend getmail, as you can do a great deal of basic filtering within version 4. You can always add more sophisticated stuff later.

Procmail appears a lot more intimidating than it really is: it appears nerve-wracking when you first read up on it, and it can indeed do an awful lot. For our simple case, to replace what KMail does, you end up with just a few really simple lines that do just about everything you need: this is especially true if your ISP or mail provider does halfway-decent spam filtering, which most do nowadays. Having said that, I still get spam, most likely because of being on mailing lists, so I intend to add more rules based on the excellent procmail quickstart at some point.

The first thing I had to do was work out KMail's directory structure. The issue is with subfolders, eg I had several folders underneath inbox for mailing lists, one for bugs, and one for Work. Maildir folders have a very specific structure: they have 3 folders within them, cur new and tmp, and nothing else. To get round this, KMail uses a hidden subfolder of the parent directory of the Maildir folder, to store any subfolders it might contain. eg: subfolders of ~/Mail/inbox live in ~/Mail/.inbox_subfolder or something: I can't remember the exact format of the name, I'm afraid I lost my notes on that. That hidden folder is a normal folder, containing any subdirectory Maildir folders. Should they have any further subfolders, they're also .hidden in this normal folder. Scout around with ls -a and you'll find them.

Basically what you want to do is bring out each Maildir folder (they're not .hidden, but will be contained in a .hidden folder, and they'll have a cur, new and tmp folder within them containing your mail) up into the visible hierarchy under ~/Mail. I just did:
Code:
mkdir -p ~/Mail/Subdir
to make a new Subdir top-level folder, and then
Code:
cd ~/Mail
mv .inbox_hiddenfolder/*/ Subdir/

These folders are then easy for you to select from mutt's 'c' menu, and they're also available to the sidebar, which gives you an explorer like feel similar to a Kmail (or any other email client) window.

The main change with getmail 4, is that you need a configuration file per email account you retrieve from: this tells getmail how to handle each account separately, and allows you to use custom filtering for each one. This can be useful if you have a personal and a work email, for example.
getmailrc-examples wrote:
You need one file for each mail account you want to retrieve mail from. These files should be placed in your
getmail configuration/data directory (default: $HOME/.getmail/). If you only need one rc file, name it getmailrc in that directory, and you won't need to supply any commandline options to run getmail.


When it comes to tying it all together, mutt config starts in /etc/Muttrc where you can set site defaults like locale.
Code:

# Please don't add settings to this file to change other user
# preferences (such as colors), since those can be hard for a user to
# undo if their preference doesn't match yours!  For example, it is
# *impossible* currently in mutt to remove color settings from objects
# other than the index.

set locale="en_GB.UTF-8"
set send_charset="UTF-8"
# do not perform Q-P or base64 encoding on legal 8-bit chars
set allow_8bit=no
# do not base64 encode 8-bit subject: line (RFC2047)
set mime_subject=no
# if no charset on incoming
set assumed_charset="ISO-8859-1"

set mbox_type=Maildir
set folder=~/Mail
set spoolfile=+/inbox
set record=+/sent-mail
set postponed=+/drafts
set trash=+/trash
# default inbox (can add more in ~/.muttrc)
mailboxes =inbox

set alias_file=~/.mail_aliases

I leave the warning there, though for my machine this is fine. I also set things so that by default on my home machine, user accounts use my ISP, and 'i' (inn or internet news reading) uses gmane:
Code:

# default pop3 server, if not using external MTA, eg fetchmail, getmail
set pop_host="mail.example.isp"

set smtp_url="smtp://smtp.example.isp"

set news_server="news.gmane.org"

# use localhost in message ID by default
set hostname="localhost"

# qualify all local addresses with the value of $hostname
set use_domain=no

# check folders for new mail every 5 minutes, not 5 seconds (!)
set mail_check=300

# no check for modified maildir files (one stat per msg on folder open)
set maildir_header_cache_verify=no

# time til op on newsgroup (not post) -> check for news. default 60
set nntp_poll=300

# skip host name part of $hostname variable when adding domain part
#  to addresses: does not affect message ID
#set hidden_host=yes

The rest is the default Gentoo stuff, commented out where not applicable (so I can compare for changes easily in dispatch-conf when there are etc-updates.)
Code:

# Maybe we shouldn't set index_format here, but this is a recommended
# one for maildir-style folders.
# - added %M: num hidden msgs when thread collapsed

set index_format="%4C %Z %{%b %d} %-16.16L %M %s"

# Gentoo predilection for maildir folders.
#set folder=~/.maildir
#set spoolfile=~/.maildir/
#set record=~/.maildir-sent/


Last edited by steveL on Mon Dec 24, 2012 12:32 am; edited 1 time in total
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2452
Location: The Peanut Gallery

PostPosted: Sun Dec 23, 2012 11:26 pm    Post subject: Reply with quote

Now this is the individual ~/.muttrc file:
Code:
# Set up for multiple accounts, with fetch via getmail, filtered via procmail
# http://wiki.mutt.org/?UserStory/MultipleAccounts -- updated for getmail-4
#

# mkdir -p ~/.cache/mutt/header
set header_cache=~/.cache/mutt/header

set time_inc=60

# personality settings
set realname = "Work Name"
set from = "wname@work.isp.tld"
alternates "hname@home.isp.tld|nick@example.isp.tld"

# respond to emails using name they were sent to, if it's one of my addresses
set reverse_name=yes

# use localhost in message ID by default
set hostname="localhost"
# qualify all local addresses with the value of $hostname
set use_domain=no
# tell the world what version of mutt we use
set user_agent=no

# signature file must exist
#set signature = ~/.signature

# automatically verify signed messages
set pgp_verify_sig=no

# Get mail via getmail and multiple accounts
macro index,browser g '!getmail --rcfile ~/.getmail/getmailrc_wname --rcfile ~/.getmail/getmailrc_hname<enter>' 'Get Mail'

This is the main part that triggers using getmail to fetch our email when we press g. Note that we pass the two rcfiles, one for each email account.

Since we're using multiple accounts we need to be able to select the one we send from:
Code:
# choose From in compose screen
# http://dev.mutt.org/trac/wiki/ConfigTricks#SetFromheaderbeforesending
alias id_work   Work Name   <wname@work.isp.tld>
alias id_home   Home Name   <hname@home.isp.tld>
alias id_nick   Nick Name   <nick@example.isp.tld>

macro compose f '<edit-from>^Uid_<tab>' 'Select From'

Here we shell out to find the list of Subdirectories:
Code:
# extra mailboxes we want to monitor for new mail/ in sidebar
mailboxes `echo ~/Mail/Subdir/*`

# mailing lists we get email for
mailboxes `echo ~/Mail/List/*`
# tell mutt about them (regexp)
subscribe ^help-bash@gnu\\.org$ ^proaudio@lists\\.tuxfamily\\.org$ ^linux-btrfs@vger\\.kernel\\.org$
# subscribe: means mutt will set Mail-Followup-To, and Shift-L knows list
# this works in nntp reader
subscribe ^distro-.*@lists\\.DISTRO\\.org$


Again, since we use multiple accounts, we want to respond accordingly when we're in various folders:
Code:
# Folder Hooks: as we change folders, we can affect settings (need first default)
folder-hook . 'set from="hname@home.isp.tld"; set record="+/sent-mail"'
# For most folders, we want our emails threaded with what we are replying to
folder-hook =inbox   'set record="+/inbox"'
folder-hook =Subdir/Work  'set from="wname@work.isp.tld"; set record="+/Subdir/Work"'
folder-hook =Subdir/nick  'set from="nick@example.isp.tld"; set record="+/Subdir/nick"'
folder-hook =Subdir/SomeProject 'set from="hname@home.isp.tld"; set record="+/Subdir/SomeProject"'
# Mailing lists: again we want our replies threaded with posts
folder-hook =List/help-bash 'set record="+/List/help-bash"'
folder-hook =List/btrfs 'set from="hname@home.isp.tld"; set record="+/List/btrfs"'
folder-hook =List/proaudio 'set from="hname@home.isp.tld"; set record="+/List/proaudio"'
# want to be able to bulk clear out job mailouts and bugs folders
folder-hook =Subdir/jobs  'set record="+/Sent/jobs"'
folder-hook =Subdir/distro-bugs  'set record="+/Sent/distro"'


# automatically abort replies if message unchanged
set abort_unmodified=yes
# edit the message header when composing
set edit_headers=yes

# Send Hooks: change settings before we send (headers in compose after this)
# Again, must have a default
send-hook .   'set realname="Home Name"; set hostname="localhost"; set signature="~/.signature/default"'

send-hook '~f .*@work\\.isp\\.tld' 'set hostname="work.isp.tld"'
send-hook '~f .*@home\\.isp\\.tld' 'set hostname="home.isp.tld"'
send-hook '~f .*@example\\.isp\\.tld' 'set hostname="example.isp.tld"'

send-hook '~f wname@work\\.isp\\.tld'    'set realname="Work Name"; set signature="~/.signature/work"'
send-hook '~f nick@example\\.isp\\.tld'  'set realname="Nick Name"; set signature="~/.signature/nick"'

# Force using nick name account for DISTRO.org NB: bounces will not get these two
# if sending to a list, use the list signature
send-hook '~t "distro-.*@lists\\.DISTRO\\.org"' 'set signature="~/.signature/distro-list"; set hostname="MLexample.isp.tld"'
send-hook '~t "@[^ <>@]*DISTRO\\.org"' 'set record="+/Sent/distro"; set hostname="example.isp.tld"; my_hdr From: "Nick Name" <nick@example.isp.tld>'

I'm pretty sure the 'set record="+/$folder"' part could be generic, in the default hook. If you know how, tell us. :)

The rest of the file is standard config to change as you wish. The sidebar is set up based on the mailboxes set above.
Code:
# aliases: (nick -> address) lookup
#source ~/.mail_aliases

# mark new unread message as old when leaving mailbox
set mark_old=no

# primary sorting method (mail lists etc)
set sort=threads
set strict_threads=yes
# how to sort subthreads
#set sort_aux=reverse-date
# date of the last message in thread
set sort_aux=reverse-last-date

# how to sort files in the dir browser
set sort_browser=reverse-date

# pager shows parts having a mailcap viewer
# set implicit_autoview=yes
# set mailcap_path="~/.mailcap"

# we want to see some MIME types inline (needs mailcap entry)
#auto_view application/msword
#auto_view application/pdf

# make default search pattern to search in To, Cc and Subject
#set simple_search="~f %s | ~C %s | ~s %s"

# show spam score (from SpamAssassin only) when reading a message
#spam "X-Spam-Score: ([0-9\\.]+).*" "SA: %1"

set pager_format = " %C - %[%H:%M] %.20v, %s%* %?H? [%H] ?"

#ignore           Received Original-Received
# do not show all headers, just a few
ignore          *
unignore        From To Cc Bcc Date Subject List-Id Reply-To User-Agent Delivered-To X-Originally-To
# and in this order
unhdr_order     *
hdr_order       From: To: Cc: Bcc: Date: Subject: List-Id: Reply-To: User-Agent: Delivered-To: X-Originally-To:

# brighten up stuff with colours, for more colouring examples see:
# http://aperiodic.net/phil/configs/mutt/colors
color normal      white          black
color hdrdefault  green          default
color quoted      green          default
color quoted1     yellow         default
color quoted2     brightblue     default
color signature   cyan           default
color indicator   brightyellow   red
color error       brightred      default
color status      brightwhite    blue
color tree        brightmagenta  black
color tilde       blue           default
color attachment  brightyellow   default
color markers     brightred      default
color message     white          black
color search      brightwhite    magenta
color bold        brightyellow   default
# black progress bar at the bottom of the screen
color progress    white          black

color header brightgreen default ^(From|Subject):
color body cyan default "(ftp|http|https)://[^ ]+"   # point out URLs
color body cyan default [-a-z_0-9.]+@[-a-z_0-9.]+    # e-mail addresses
color underline brightgreen default

bind  pager   <up>     previous-line
bind  pager   <down>   next-line
bind  pager   <left>   exit
bind  pager   <right>  view-attachments
bind  attach  <left>   exit
bind  attach  <right>  view-attach
bind  index   <right>  display-message
macro index   <left>   "<change-folder>?" "Select folder"
bind  browser <right>  select-entry
macro browser <left>   "<exit><change-folder>!<Enter>" "Return to folder"

# set up the sidebar, default not visible
set sidebar_width=25
set sidebar_visible=yes
set sidebar_delim='|'
set sidebar_sort=yes

# color of folders with new mail
color sidebar_new yellow default
# ctrl-n, ctrl-p to select next, prev folder
# ctrl-o to open selected folder
bind index,pager \CP sidebar-prev
bind index,pager \CN sidebar-next
bind index,pager \CO sidebar-open

# only if many mailboxes
#sidebar-scroll-up
#sidebar-scroll-down

# %B: mailbox name
# %N %F %S: number new, flagged; total size
# %!: ! if 1 flagged, !! if 2, or n! if more than 2
#set sidebar_format="%B: %N %! (%S)"

# indent folders in sidebar
#set sidebar_folderident=yes

# b toggles sidebar visibility
macro index b '<enter-command>toggle sidebar_visible<enter><refresh>' "Sidebar on/off"

# Remap bounce-message function to B
bind index B bounce-message


Last edited by steveL on Mon Dec 24, 2012 12:58 am; edited 2 times in total
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2452
Location: The Peanut Gallery

PostPosted: Sun Dec 23, 2012 11:31 pm    Post subject: Reply with quote

This is ~/.getmail/getmailrc_template (cp to getmailrc_name):
Code:
# To use this template replace <IDENTITY> with the nickname you want to use as
# the account handle: the default one should be your login on this machine

# Simple single-user POP3 account
[retriever]
type = SimplePOP3Retriever
server = mail.example.com
username = LOGIN1@example.com
#!!! MAKE SURE you run: chmod 0700 ~/.getmail  # if you didn't: mkdir -m 0700
password = PASSWD1
#!!!
# Use APOP authentication for this account instead of cleartext PASS
#use_apop = 0

# Deliver via procmail
[destination]
type = MDA_external
path = /usr/bin/procmail
# Use -f option rather than prepend mboxrd-style "From " line (unixfrom = 1)
# -f-  simply ensures unixfrom has correct timestamp
# getmailrc-examples # 11 shows use of $HOME
arguments = ("-f", "%(sender)", "-m", "$HOME/.procmail/<IDENTITY>_rc")

[options]
# Retrieve all messages
readall = 1
# Delete mail after retrieval
delete = 1
# Don't add a Delivered-To: header
delivered_to = 0
# Don't add a Received: header
received = 0
# debug: "msg x/y (N bytes) delivered, deleted" (defaults to 1)
verbose = 0
# debug: Log message retrieval and delivery
#message_log = ~/.getmail/<IDENTITY>.log
# Default: don't log

# TCP timeout value; increase if on a poor connection or slow POP3 server
# getmail defaults to a 180 second (3 min) timeout
#timeout = 300

# Default is 0, which means no limit (otherwise n bytes)
#max_message_size = 0

and this is what a real in-use one looks like:
Code:
[retriever]
type = SimplePOP3Retriever
server = mail.example.com
username = steve@example.com
password = PASSWD1

[destination]
type = MDA_external
path = /usr/bin/procmail
arguments = ("-f", "%(sender)", "-m", "$HOME/.procmail/steve_rc")

[options]
readall = 1
delete = 1
delivered_to = 0
received = 0
#verbose = 0

#message_log = ~/.getmail/steve.log

#max_message_size = 0

I leave the max_message_size there in case I come up against some huge email, so I can tweak it. The log is not very useful in and of itself, once you've got the right username and password.


Last edited by steveL on Mon Dec 24, 2012 12:21 am; edited 1 time in total
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2452
Location: The Peanut Gallery

PostPosted: Sun Dec 23, 2012 11:38 pm    Post subject: Reply with quote

procmail starts with /etc/procmailrc where we set some defaults:
Code:
# Use maildir-style mailbox in user's home directory
# "The MAILDIR variable specifies Procmail's working directory and all relative
#  paths are relative to this directory."
# NB: MAILDIR must NOT end in a slash
# - cf: http://www.ii.com/internet/robots/procmail/qs/#steps
MAILDIR=$HOME/Mail
# NB: maildir storage directories must end with / and need procmail-3.22+
DEFAULT=$MAILDIR/inbox/
# must set SHELL
SHELL=/bin/bb
# for use in LOG=
EOL='
'
PMDIR=$HOME/.procmail
# debug: backups go under here
# as root: mkdir -m 0700 it first, then: chown <LOGNAME>:<LOGNAME|users>
SAVE=/var/spool/mail/$LOGNAME

NOTE If you don't have busybox, you should change to: SHELL=/bin/sh. It just makes things quicker for default installs using Bash.


Last edited by steveL on Sun Feb 24, 2013 3:28 pm; edited 1 time in total
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2452
Location: The Peanut Gallery

PostPosted: Sun Dec 23, 2012 11:43 pm    Post subject: Reply with quote

Finally, the template procmail rc file. This is far more verbose than it needs to be: I just keep it in ~/.procmail/template_rc for documentation.
Code:
# QuickStart: http://www.ii.com/internet/robots/procmail/qs/
# Tips:       http://pm-doc.sourceforge.net/doc/
# make sure you run: chmod 0700 ~/.procmail
# For multiple accounts
# we use ${IDENTITY}_rc and ${IDENTITY}_bulk_rc files under ~/.procmail directory
# cf: http://www.cyberciti.biz/faq/procmail-suspicious-rcfile-message-homeuserprocmailrc-solution/

# /etc/procmailrc is not read under -m; it sets:
#   MAILDIR=$HOME/Mail        (procmail working directory)
#   DEFAULT=$MAILDIR/inbox/   (maildir format)
#   PMDIR=$HOME/.procmail     (user procmail files)
#   SHELL and EOL
INCLUDERC=/etc/procmailrc

# multiple accounts: if non-default, change $LOGNAME to <nickname>
IDENTITY=$LOGNAME
# ONLY if non-default identity/account (you might want to capitalise initial):
## DEFAULT=$MAILDIR/Subdir/$IDENTITY/

# setting LOCKFILE serialises procmail
# - use   :0:   or   :0 <flags> :   if not delivering to a maildir directory
## LOCKFILE=$PMDIR/$IDENTITY.$LOCKEXT

# must have a logfile, or errors and diagnostics mailed to sender(!)
LOGFILE=$PMDIR/$IDENTITY.log

# Our ISP does spam filtering (most do nowadays as it cuts down on traffic.)

# Solicited bulk email: not worried about backups
INCLUDERC=$PMDIR/${IDENTITY}_bulk_rc

# debug|test: save copies in case we screw up (let procmail make the maildir tree)
## :0 c
## $SAVE/backup/

# NB: all 'log:' items are redundant if VERBOSE is yes/1/true
# log: insert blank line before each non-bulk message's $LOGFILE entry
## LOG = $EOL
# log: summary
## LOGABSTRACT=yes
# debug: extended diagnostics
## VERBOSE=yes

# Filter based on header
:0
* ^X-Originally-To: alias@example\.com
Subdir/Alias/
# just in case (this is frowned on: any CC:(etc) to this address will also
#  match, even if using another address as To: -- this may be what you want
#  eg if it's work-related, but it usually is not.)
# The logging is there to show how a log message is attached for one rule
#  - it's used in debugging.
#  Otherwise this rule doesn't need a subsidiary, tho this is how to do one.
:0
* ^TO_alias@example\.com
{
   # log:
   #LOG = Catch-all$EOL
   :0
   Subdir/Alias/
}

# Like this (or if you don't have a header: bear in mind caveats)
:0
* ^TO_alias@example\.com
Subdir/Alias/

# if DEFAULT as maildir doesn't work (it does on gentoo, since 3.22-r9)
## :0
## $DEFAULT

Note the line: INCLUDERC=$PMDIR/${IDENTITY}_bulk_rc which we use to include all our bulk mailer stuff like mailing lists. This is useful as you use that file to test the rules and your setup without going through getmail.


Last edited by steveL on Mon Dec 24, 2012 1:30 am; edited 1 time in total
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2452
Location: The Peanut Gallery

PostPosted: Sun Dec 23, 2012 11:55 pm    Post subject: Reply with quote

This is what an actual procmailrc file looks like for the default user:
Code:
INCLUDERC=/etc/procmailrc
IDENTITY=$LOGNAME
LOGFILE=$PMDIR/$IDENTITY.log

# Bulk email
INCLUDERC=$PMDIR/${IDENTITY}_bulk_rc

# debug|test:
## :0 c
## $SAVE/backup/

## LOG = $EOL
## LOGABSTRACT=yes
# debug:
## VERBOSE=yes

:0
* ^TO_nick@example\.isp\.tld
Subdir/nick/

And for a secondary account:
Code:
INCLUDERC=/etc/procmailrc
IDENTITY=work
DEFAULT=$MAILDIR/Subdir/Work/

LOGFILE=$PMDIR/$IDENTITY.log

LOGABSTRACT=no
INCLUDERC=$PMDIR/${IDENTITY}_bulk_rc

# debug:
## :0 c
## $SAVE/backup/

##LOG = $EOL
##LOGABSTRACT=yes
# debug: extended diagnostics
## VERBOSE=yes

:0
* ^TO_igli@example\.isp.\tld
Subdir/igli/

And a bulk file as included:
Code:
# identity_bulk_rc: mailing list subscriptions (aka Solicited Bulk Email.)
# separate file means we can test on a message with:
#  procmail "MAILDIR=/tmp/Mail$$" DEFAULT=/dev/null ~/.procmail/${identity}_bulk_rc < "$msg"
#  - this will give sth like: procmail: Couldn't chdir to "/tmp/Mail2920"
#  - but we can still check that a filter matches (nothing gets written)
# see: http://pm-doc.sourceforge.net/doc/#dry_run_testing

:0
* ^List-Id: <help-bash\.gnu\.org>
List/help-bash/

:0
* ^From[ :].*@(theitjobboard\.co\.uk|realstaffing\.com|huxley\.com)>
Subdir/jobs/

Here's another bulk_rc, to show you that you end up with just a few simple lines:
Code:
:0
* ^List-ID: proaudio\.lists\.tuxfamily\.org
List/proaudio/

:0
* ^List-ID: <linux-btrfs\.vger\.kernel\.org>
List/btrfs/

:0
* ^From:? bugzilla-daemon@gentoo\.org
Subdir/gentoo-bugs/


And that should be enough to get you started: you just press 'g' in mutt to download your emails.

One note: Make sure you terminate your destination mail folders in procmail with a / for the them to considered Maildir format. That'll mean no locking is required, and procmail will create the folders correctly (with cur, new and tmp) as needed. Leaving it off will mess things up, since that means mbox format, which requires locking (and is slower, not as robust..) Also, note that there are at least two types of regex you have to deal with: mutt and procmail, with different escaping (and you can do matching in getmail as well: just see the sample file.)

I recommend using the qdbm backend, it works really well with the header-caching. I thought I'd have to get notmuch on to my email, but it's not been an issue at all.

Constructive comments and improvements most welcome. (I don't want to argue about the choices I've made: just to share knowledge.)

HTH,
steveL.
_________________
creaker wrote:
systemd. It is a really ass pain

update - "a most excellent portage wrapper"

#friendly-coders -- We're still here for you™ ;)


Last edited by steveL on Mon Dec 24, 2012 1:13 am; edited 2 times in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31879
Location: 56N 3W

PostPosted: Sun Dec 23, 2012 11:59 pm    Post subject: Reply with quote

steveL,

Thanks. I use Balsa in Gnome, it uses maildir if you want, but I will need to ditch Gnome when systemd is no longer optional and with it. Balsa.

Bookmarked for later
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2452
Location: The Peanut Gallery

PostPosted: Mon Dec 24, 2012 12:27 am    Post subject: Reply with quote

Hey Neddy,

I could have sworn I looked at all of them, and none of the others used Maildir properly. I probably didn't consider balsa because of the Gnome dep, though.

In any event, I'm really happy I've switched, as mutt is excellent, and very lightweight. It's also excellent for IMAP apparently, which I don't use. procmail is incredibly capable, yet such a small download! Gives you faith in the Unix philosophy :)
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2452
Location: The Peanut Gallery

PostPosted: Sun May 19, 2013 2:25 pm    Post subject: Spam filtering Reply with quote

Ago wrote a great write-up of procmail spam filtering recently.

Just keeping a link here, for anyone who's setting up procmail. AFAIK the X-Spam headers have to be inserted by your ISP or email provider; some hosted email providers and ISPs insert them, others don't.

If you set up procmail (spam filtering etc), please do share configurations and tricks that work, if you know some :)
Back to top
View user's profile Send private message
khayyam
Advocate
Advocate


Joined: 07 Jun 2012
Posts: 2244

PostPosted: Wed May 22, 2013 7:46 pm    Post subject: Reply with quote

steveL ...

as requested here is how to setup net-mail/notmuch for use with mutt. First enable the 'mutt' useflag and emerge notmuch, this should provide the various notmuch components and the 'notmuch-mutt' perl script. You then run 'notmuch setup' which will create the ~/.notmuch-config (with the path to the maildir) and index all the mail, creating its data in the root of the maildir (eg: ~/mail/.notmuch).

In order to have new mail indexed the MDA needs to call 'notmuch new' after mail delivery, I use offlineimap which has a 'postsynchook' for this purpose. It generally only takes a second or so to update the index.

Add the following to the .muttrc (or .mutt/keybindings dependent on your particular mutt setup ... I tend to prefer seperate configs for hooks, keybindings, gpg, etc).

Code:
# notmuch-mutt
macro index <F8> \
    "<enter-command>unset wait_key<enter><shell-escape>notmuch-mutt --prompt search<enter><change-folder-readonly>`echo $HOME/tmp/notmuch/mutt/results`<enter>" \
    "notmuch: search mail"
macro index <F9> \
    "<enter-command>unset wait_key<enter><pipe-message>notmuch-mutt thread<enter><change-folder-readonly>`echo $HOME/tmp/notmuch/mutt/results`<enter><enter-command>set wait_key<enter>" \
    "notmuch: reconstruct thread"

Note: ~/tmp will need to exist prior, or can be changed to some other directory.

With the above F8 will prompt for a search term and provide matches from notmuch's index in a new mailbox, F9 will then provide the thread with the selected mail from the search.

Though mutt has some builtin search capabilities (using 'limit' or "/") the above is useful if your mail is spread over many mailboxes as your search term doesn't need to be limited to the current mailbox, and creating mailboxes on the fly by thread is quite useful. That said I'm not sure how much longer I will continue to use the above setup as notmuch (dependencies included) seems fairly heavy for such a small feature, though if you make use of it in other ways it if might be less so.

best ... khay
Back to top
View user's profile Send private message
Princess Nell
Guru
Guru


Joined: 15 Apr 2005
Posts: 525

PostPosted: Thu May 23, 2013 8:36 pm    Post subject: Reply with quote

Ago's procmail recipes are probably the worst and most inefficient I have seen in a over a decade.

I also think there are better ways to filter spam ...
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2452
Location: The Peanut Gallery

PostPosted: Fri May 24, 2013 10:47 am    Post subject: Reply with quote

Princess Nell wrote:
Ago's procmail recipes are probably the worst and most inefficient I have seen in a over a decade.

Yeah they are a bit beginner-ish, but it's still nice to see someone write up anything: no-one else even discusses procmail.
Quote:
I also think there are better ways to filter spam ...

Care to elaborate?
Back to top
View user's profile Send private message
ecko
n00b
n00b


Joined: 04 Jul 2010
Posts: 61

PostPosted: Thu Jun 06, 2013 12:57 pm    Post subject: Reply with quote

Thanks for the tutorial. I had a similar experience : elm user at University, kde user since 2003, I had to give up with kmail when it stopped deserving trust, being using webmails for more than a year and now switching to Mutt, where my people belong.
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2452
Location: The Peanut Gallery

PostPosted: Sat Jun 08, 2013 12:42 pm    Post subject: Reply with quote

ecko wrote:
Thanks for the tutorial. I had a similar experience : elm user at University, kde user since 2003, I had to give up with kmail when it stopped deserving trust, being using webmails for more than a year and now switching to Mutt, where my people belong.

Heh yw; yeah I went for 9 months with no email, and very occasional webmail check. I can't tell you the difference to my machine, not having to run all that nonsense. Now email is as lightweight as running nano editor; I just hit F12 for yakuake and type in mutt, and it's quick and simple, just like the good old days.

It makes a change when your biggest worry is your net connection, instead of wrestling with the latest bugs in a rubbish design, and waiting for your desktop to load a mysql server and 3 different database layers.. Couldn't be happier with mutt :-)

Let us know how you get on, or any tips or changes you think would be useful.

Also, you might like Dominique's guide to getting rid of *kit if you're into a light-weight desktop. I use that and udev without an initramfs and, mainly because of getting rid of semantic-craptop admittedly, KDE-4.9 feels like 3.5 again (I've been holding off on 4.10 since there were some issues, but 4.10.3-r2 just went stable so I think I'll update now.)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum