Skip to content →

Mutt, Procmail and Nbsmtp on Gentoo.

I got around to getting Mutt, Promail and Nbsmtp running on my gentoo box. Mainly so I can check my mail where ever I am at. Here are the steps I used to get it all going.

1. First emerge the programs needed

# emerge fetchmail procmail mutt nbsmtp

2. Then edit the “.fetchmailrc” in your home directory. And of course you need to change the settings to reflect your settings.

poll mail.myisp.net protocol pop3 user “myname” password “mypasswd”

and then chmod .fetchmailrc to 600

3. Test out fetchmail, also leave the “k” flag so it will leave the messages on the server.

fetchmail -akv -m “/usr/bin/procmail -d %T”

4. Now edit the .procmailrc in your home directory. This is the sample one I got online.

MAILDIR=$HOME/MuttMail ##you better make sure it exists
LOGFILE=$HOME/.procmaillog
LOGABSTRACT=no
#VERBOSE=on…is only used for debugging
VERBOSE=off
FORMAIL=/usr/bin/formail
NL=”

##recipe lines begin with :0
##dont put comments on recipe lines
##disable a recipe with the false condition !
##condition lines begin with * and regex is your friend
##conditions are anded and everything after * is fed straight into egrep
##one action line follows the conditions, in this case it is a mailbox name

#catch duplicates using formail
:0 Whc: .msgid.lock
| $FORMAIL -D 16384 .msgid.cache

:0 a
$MAILDIR/duplicates

#people we always allow mail from
:0
* ^From:.*(craig\@hotmail|renee\@local.com)
$MAILDIR/friends

#now flush some spam out
:0
* ^Subject:.*(credit|cash|money|debt|sex|sale|loan)
$MAILDIR/spam

#no more html messages
:0
* ^Content-Type:.*html
$MAILDIR/junk

#now put my mail lists into mailboxes
:0
* ^List-Id:.*gentoo-user
gentoo-user

:0
* ^List-Id:.*gentoo-dev
gentoo-dev

:0
* ^List-Id:.*gentoo-announce
gentoo-announce

#catch any other gentoo mail
:0
* ^From:.*gentoo.org
gentoo

:0
* ^From:.*@freshmeat\.net
freshmeat

################################
# Last rule: mail that gets #
# this far goes in default box #
################################
:0
* .*
default

# End of file

5. Now test fetchmail again. Once again take note that you are still using the “k” flag.

fetchmail -akv -m “/usr/bin/procmail -d %T”

6. Create a “.muttrc” in your home directory and make it look like this, or somewhat close to this.

set pager_context=1
set pager_index_lines=6 #show a mini-index in pager
set menu_scroll
set pgp_verify_sig=no #dont show pgp in pager
set status_on_top #put status line at top
set sort=threads #sort by message threads in index

set status_format=” %r %b %f %n Del %d Msgs %m %l %> (%P)”
set pager_format=”%-10.10i %[!%a %b %d %R]”
set date_format=”!%H:%M %a %d %b ”
set index_format=”%4C %Z %[%b%d] %-15.15F %s”
set folder_format=”%2C %t %8s %d %N %f”

#set sendmail=”/usr/bin/nbsmtp -d isp.net -h smtp.isp.net -f yourname@isp.net”

#set from=”default-mailaddress” #set to your from address
#set realname=”myname”

set record=”$HOME/MuttMail/sent” #sent mail is saved here
set delete=yes #delete without prompting
set include=yes #quote msg in reply
set fast_reply=yes #no prompting on reply
set beep=no #no noise
set markers=no #no + on wrapped lines
set confirmappend=no #no prompt for save to =keep
set to_chars=” +TCF” #no L for mail_list

set folder = $HOME/MuttMail
mailboxes =gentoo-user
mailboxes =gentoo-dev
mailboxes =gentoo-announce
mailboxes =gentoo
mailboxes =freshmeat
mailboxes =duplicates
mailboxes =default
mailboxes =friends
mailboxes =junk
mailboxes =spam
mailboxes =keep

save-hook .* =keep #default mbox to (s)ave mail is =keep
subscribe gentoo-user gentoo-dev #subscribed to these lists

bind pager h display-toggle-weed #toggle headers with h key

# simulate the old url menu
macro index \cb |urlview\n ‘call urlview to extract URLs out of a message’
macro pager \cb |urlview\n ‘call urlview to extract URLs out of a message’

#run fetchmail by hitting key of G
macro index G “!fetchmail -a -m ‘procmail -d %T’\r”
macro pager G “!fetchmail -a -m ‘procmail -d %T’\r”

#use to edit .muttrc and then source it…no restart necessary
macro generic ,sm “:source $HOME/.muttrc\r”
#macro generic \cj “!rxvt -bg wheat -e joe $HOME/.muttrc\r”

# default list of header fields to weed out when displaying mail
#ignore them all and then unignore what you want to see
ignore *
unignore Date To From: Subject X-Mailer Organization User-Agent
hdr_order Date From To Subject X-Mailer User-Agent Organization

##your Mutt has to have some colors
##these are for four levels of quoted text
##they override the system settings in /etc/mutt/Muttrc

#color quoted green default
color quoted1 magenta blue
#color quoted2 yellow default
#color quoted3 red default
#color signature cyan cyan

#this color setup is copied from /etc/mutt/Muttrc.color
#comment it out if you want the default colors in /etc/mutt/Muttrc
# Je vois la vie en rose 🙂
color hdrdefault brightcyan blue
color header brightwhite blue “^from:”
color header brightwhite blue “^subject:”

color quoted brightgreen blue
color signature brightwhite blue

color indicator blue green

color error red black
mono error bold
color status black cyan
mono status bold
color tree yellow blue

color tilde brightmagenta blue
color body brightwhite blue “[-a-z_0-9.]+@[-a-z_0-9.]+”
mono body bold “[-a-z_0-9.]+@[-a-z_0-9.]+”
color body brightyellow black “^Good signature”
mono body bold “^Good signature”
color body brightwhite red “^Bad signature from.*”
mono body bold “^Bad signature from.*”
color normal white blue
color message green black
color attachment brightgreen blue

# End of file

And once again tweak this to the settings you want. I had to make my smtp like look like this (set sendmail=”/usr/bin/nbsmtp -U username -P password -d isp.net -h smtp.isp.net -f urname@isp.net”) so that I could send mail correctly…

7. That should be all set, start up mutt with “mutt -y” and it should work jsut fine.

Published in Linux Technology

%d bloggers like this: