Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Package:Mutt

From Funtoo
Revision as of 00:50, June 27, 2014 by Duncan.britton (talk | contribs)
Jump to navigation Jump to search

Mutt

   Tip

We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.


This page was created as a good place for people to place their mutt configurations to share with others. These configuration settings go in the user's ~/.muttrc file.

Installing Mutt

To install mutt, emerge it:

root # emerge mutt

Essential Mutt

set pager_stop

This turns off the default behavior of mutt where hitting space to scroll will automatically move to the next message when the end of the current message is reached. This is very annoying when scrolling in long emails like cron jobs.

angry_vincent's .muttrc:

   ~/.muttrc
# General config
# ---------------

set folder=~/Mail		   # mail folder
set alias_file=~/.mail_aliases     # alises file
set arrow_cursor		   # cursor is '->'
set attribution="%d, %n wrote:"    # beginning of mail answer
set copy=yes			   # save mail copies
set edit_headers		   # edit mail header
set editor="vim"		                              # editor
set folder_format="%t%N %-30.30f %8s"                         # folder list look
set index_format="%4C %Z %{%b %d} %-31.31F %N (%4c) %s"       # mail list look 
set mailcap_path="~/.mailcap"	                              # path to .mailcap
set menu_scroll			# scroll list by one line
set mail_check=5		# mail check interval
set pager_stop 			# at the end of mail do not move to next message 
set postponed=+drafts		# postponed mails
set print=ask-yes		# ask before print
set print_command=lpr		# print command
set record=+sent		# where to save sent mails 
set signature="~/.signature"	# signature file
set visual=vim                  # editor caled by  ~v

# mail sort
set sort=threads
set sort_aux=reverse-date-received
set sort_browser=reverse-date
ignore *     # ignore headers so the mail body is not overloaded
unignore        from: subject to cc mail-followup-to \
                date x-mailer x-url user-agent reply-to   # fieids i like to see in mail body

# Colors
color index brightcyan black ~N
color index brightyellow black ~F
color index black green ~T
color index brightred black ~D
mono index bold ~N
mono index bold ~F
mono index bold ~T
mono index bold ~D

# Highlights inside the body of a message.

# URLs
color body brightgreen black "(http

Interesting Color Options

Golodhrim's mutt config

First, I split up my muttconfig in several subfiles under ~/.mutt. The resulting files are:

  • ~/.mutt/account_hooks
  • ~/.mutt/colors
  • ~/.mutt/folder_hooks
  • ~/.mutt/gpg
  • ~/.mutt/lists
  • ~/.mutt/macros
  • ~/.mutt/mutt-alias
  • ~/.mutt/muttrc
  • ~/.mutt/sidebar
  • ~/.secret/.passwd.gpg

account_hooks

   ~/.mutt/account_hooks
#-------------------------------------------------------------------------
# Account Hooks
#-------------------------------------------------------------------------
account-hook . 'unset imap_user imap_pass'
account-hook 'imap://user@imaphost/' "set imap_user=user imap_pass=$my_pass1 "

colors

   ~/.mutt/colors
#-------------------------------------------------------------------------      
# Set colors
#-------------------------------------------------------------------------
color   attachment  brightmagenta       default
color   error       brightred           default
color   hdrdefault  red                 default
color   indicator   brightyellow        red
color   markers     brightcyan          default
color   message     brightcyan          default
color   normal      default             default
color   quoted      brightblue          default
color   search      default             green
color   signature   red                 default
color   status      yellow              blue
color   tilde       magenta             default
color   tree        magenta             default

folder_hooks

   ~/.mutt/folder_hooks
#--------------------------------------------------------------------------
# Folders, mailboxes and folder hooks
#--------------------------------------------------------------------------
# Setup for imap-user in account_hooks
set folder="imap://user@imaphost/"
mailboxes =INBOX =INBOX/Archives =INBOX/Drafts =INBOX/Sent =INBOX/Trash
folder-hook 'imap://user@imaphost/' " \
    set folder=imap://user@imaphost/ \
        postponed=+INBOX/Drafts \
        record=+INBOX/Sent \
        smtp_url=smtp://user@smtphost \
        smtp_pass=$my_pass1 \
        #signature=~/.sig/pr.txt \
        from='Name Familyname <name@host> ' \
        realname='Realname' \
        pgp_sign_as='PGP-signature' \
        spoolfile='imap://user@imaphost/' "

~/.mutt/gpg

   ~/.mutt/gpg
# vim:syn=muttrc                                                                
##

set smime_decrypt_use_default_key=yes

# Decode application/pgp attachments like so:
set pgp_decode_command="/usr/bin/gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f"

# And use this to verify pgp signatures:
set pgp_verify_command="/usr/bin/gpg --no-verbose --batch --output - --verify %s %f"

# How to decrypt pgp encrypted messages:
set pgp_decrypt_command="/usr/bin/gpg --passphrase-fd 0 --no-verbose --batch --output - %f"

# How to pgp sign a message:
set pgp_sign_command="/usr/bin/gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"

# How to pgp clearsign a message:
set pgp_clearsign_command="/usr/bin/gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"

# Import a pgp key from a message into my public keyring as follows:
set pgp_import_command="/usr/bin/gpg --no-verbose --import -v %f"

# Use this to export a key from my public keyring:
set pgp_export_command="/usr/bin/gpg --no-verbose --export --armor %r"

# Verify key information (from the key selection menu):
set pgp_verify_key_command="/usr/bin/gpg --verbose --batch --fingerprint --check-sigs %r"

# List my public keyring like so:
set pgp_list_pubring_command="/usr/bin/gpg --no-verbose --batch --with-colons --list-keys %r" 

# List my private keyring like so:
set pgp_list_secring_command="/usr/bin/gpg --no-verbose --batch --with-colons --list-secret-keys %r" 

# Automatically sign outgoing messages
set pgp_autosign=yes

# Timeout (in seconds) for cached passphrases:
set pgp_timeout=1800

# Text to show before a good signature:
set pgp_good_sign="^gpg: Good signature from"

~/.mutt/lists

   ~/.mutt/lists
#-------------------------------------------------------------------------      
# Mailinglist Subscriptions
#-------------------------------------------------------------------------
# Syntax:
# subscribe mailinglist@domain.com

~/.mutt/macros

   ~/.mutt/macros
# Macros to toggle the sidebar visibility                                       
macro index b '<enter-command>toggle sidebar_visible<enter><refresh>'
macro pager b '<enter-command>toggle sidebar_visible<enter><redraw-screen>'

# abook query
macro index,pager A "<pipe-message>abook --add-email-quiet<return>" "add the sender address to abook"
macro generic,index,pager \Cb "abook" "launch abook"

~/.mutt/alias

   ~/.mutt/alias
alias nick Realname <email@host.tld>

~/.mutt/muttrc

   ~/.mutt/muttrc
# Some minimal Mutt settings, Gentoo-style.  These reflect the Gentoo
# predilection for maildir folders.
#
# 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.

#-------------------------------------------------------------------------
# Process the password file first
#-------------------------------------------------------------------------
set my_tmp=`gpg -o ~/.secret/.tmp -d ~/.secret/.passwd.gpg`                     
set my_pass1=`awk '/user:/ {print $2}' ~/.secret/.tmp`
set my_del=`rm -f ~/.secret/.tmp`
 
#-------------------------------------------------------------------------
# Further customisations
#-------------------------------------------------------------------------
set smart_wrap = yes
set sort = 'threads'
set sort_aux = 'last-date-received'
set imap_check_subscribed

ignore "Authentication-Results:"
ignore "DoaminKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc

#-------------------------------------------------------------------------
# Configuration variables
#-------------------------------------------------------------------------
set abort_nosubject=yes
set abort_unmodified=yes
set query_command="abook --mutt-query '%s'"
set alias_file="~/.mutt/mutt-alias"
set alias_format="%4n %t %a %r"
source $alias_file
set assumed_charset="utf-8"
set attach_charset="utf-8"
set charset="utf-8"
set date_format=""
set edit_headers=yes
set editor='vim + -c "set textwidth=72" -c "set wrap" -c "set nocp" -c "?^$"        '
set folder="~/.offlineimap"
set forward_quote=yes
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
set help=yes
set imap_idle=yes
set imap_peek=yes
set imap_servernoise=no
set include=yes
set mail_check=60
set mbox_type=Maildir
set menu_move_off=no
set menu_scroll=no
set mime_forward=ask-no
set pager_context=2
set pager_stop=yes
set postponed="~/.mutt/mail/postponed"
set realname="Martin 'golodhrim' Scholz"
set record="~/.mutt/mail/sent"
set reply_regexp="^(re([\[0-9\]+])*

~/.mutt/sidebar

   ~/.mutt/sidebar
#--------------------------------------------------------------------------     
# Sidebar configuration
#--------------------------------------------------------------------------
set sidebar_width=30
set sidebar_visible=yes
set sidebar_delim='

~/.secret/.passwd.gpg

For this file follow the next steps:

  • Step 1:

Create a folder ~/.secret and inside that directory, create a file called .passwd. Add the following to it:

   ~/.secret/.passwd
user1:    passwd1
user2:    passwd2

where "user1" and "user2" are identifiers for the accounts you added in the account_hooks and folder_hooks files, as well as at the start of the muttrc.

  • Step 2:

Now, encrypt the file with your gpg-key. If you don't have one, execute gpg --gen-key and create one. After that, don't forget to delete your unencrypted password storage:

user $ gpg -r 0x<Your-ID-fingerprint> -o .passwd.gpg --encrypt .passwd
user $ rm -f .passwd

Mutt postfix setup

Postfix is another popular and powerful mail transfer agent which is easier to configure than sendmail. Let's start a quick postfix mail transfer setup that will work with mutt. Set the sasl,berkdb USE flags to mail-mta/potsfix and mail-client/mutt in /etc/portage/package.use/:

root # echo "mail-mta/postfix berkdb sasl" >> /etc/portage/package.use/mail
root # echo "mail-client/mutt berkdb sasl" >> /etc/portage/package.use/mail
root # emerge -uN1 mutt postfix

Edit /etc/postfix/main.cf and add the following lines:

   /etc/postfix/main.cf
relayhost = smtp.gmail.com:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/gmail_passwd
smtp_sasl_security_options = noanonymous

Create and edit the aforementioned authorization file: gmail_passwd:

root # touch /etc/postfix/gmail_passwd
root # echo "smtp.gmail.com:587 my.name@gmail.com:password" >> /etc/postfix/gmail_passwd

Where <my.name> is a gmail account and passwd is the account password. Convert gmail_passwd into Berkeley DB format, secure the file, and restart the postfix daemon:

root # postmap /etc/postfix/gmail_passwd
root # chown root:postfix /etc/postfix/gmail_passwd*
root # chmod 0640 /etc/postfix/gmail_passwd*
root # /etc/init.d/postfix restart