Tools Index

Mutt

Mutt is a powerfull mail reader, Mutt Manual, is the best place to find information. I recomend Jump Start: Mutt, name says it all.

1. Install

Sysdoc mutt port is a copy of opt mutt port with built in SMTP and SASL. Alternative is to use external programs like msmtp.

        $ prt-get depinst mutt cyrus-sasl
        

Verify if mutt have SMTP support;

        $ mutt -v | grep USE_SMTP
        +USE_POP  +USE_IMAP  +USE_SMTP
        

Verify if mutt have SASL support;

        $ mutt -v | grep USE_SASL
        +USE_SSL_OPENSSL  -USE_SSL_GNUTLS  +USE_SASL  -USE_GSS  +HAVE_GETADDRINFO
        

Mutt will recognize follow locations for configurations files;

/usr/etc/Muttrc
System configuration file for mutt.
~/.muttrc
User configuration file on home root.
~/.mutt/muttrc
User configuration inside home mutt folder.

Skeleton configuration will use the second user configuration (inside home mutt folder);

        $ sudo mkdir /etc/skel/.mutt
        $ sudo touch /etc/skel/.mutt/mail_alias
        

Get gpg.rc example from distribution file;

        $ tar xf /srv/ports/distfiles/mutt-1.6.1.tar.gz mutt-1.6.1/contrib/gpg.rc
        $ sudo mv mutt-1.6.1/contrib/gpg.rc /etc/skel/.mutt/
        

If you like to use sample.muttrc distributed with source code;

        $ tar -xf /srv/ports/distfiles/mutt-1.6.1.tar.gz mutt-1.6.1/contrib/sample.muttrc
        $ sudo mv mutt-1.6.1/contrib/sample.muttrc /etc/skel/.mutt/muttrc
        
        $ rm -fr mutt-1.6.1/
        

2. Configure

Justin R. Miller Mutt Gnupg Howto "Everything You Need To Know To Start Using GnuPG with Mutt" is a great reference. Multiple email accounts are gracefully handle by folder hooks, this hooks are defined in muttrc. When we change folder the hook is called, setting up the email account sepecific settings.

Lets start configuring the two accounts, one for host system email and another for external email account. Change pgp_sign_as according to your specific sub key for signing. Change muttrc with your preferences;

        $ vim ~/.mutt/muttrc
        
        set config_charset="utf-8"
        # set locale="de_CH"
        set charset="utf-8"
        set send_charset="utf-8"
        set editor="vim"
        set visual=vim
        set auto_tag
        set sort=threads

        set sort_browser=reverse-date
        set sort_aux=reverse-last-date-received
        set duplicate_threads=yes

        set crypt_use_gpgme=yes

        ## automatically sign all outgoing messages
        set crypt_autosign=yes

        ## automatically encrypt outgoing messages
        set crypt_autoencrypt=yes

        ## automatically verify the sign of a message when opened
        set crypt_verify_sig=yes

        set pgp_sign_as=0x8BF422F79FC7C975BDF07828E88440BC35095A74
        #set pgp_sign_as=0x8BF422F7
        set pgp_timeout=1800
        set pgp_autosign=yes
        #set pgp_replyencrypt=yes

        source ~/.mutt/gpg.rc

        source "~/.mutt/mail_alias"
        set alias_file=~/.mutt/mail_alias

        # Header
        set header_cache =~/.mutt/cache/headers
        set message_cachedir =~/.mutt/cache/bodies
        set certificate_file =~/.mutt/certificates

        set timeout=10    # mutt 'presses' (like) a key for you 
                          #(while you're idle) each x sec to trigger 
                          #the thing below
        set mail_check=5  # mutt checks for new mails on every keystroke
                          # but not more often then once in 5 seconds
        set beep_new      # beep on new messages in the mailboxes

        ## Local system account
        folder-hook '.mail' 'source ~/.mutt/system'

        ## Remote account
        folder-hook '.mailext' 'source ~/.mutt/external'

        ## Default account
        source ~/.mutt/system

        ## Shortcuts
        macro index,pager <f3> '<sync-mailbox><enter-command>source ~/.mutt/external<enter><change-folder>!<enter>'

        macro index,pager <f2> '<sync-mailbox><enter-command>source ~/.mutt/system<enter><change-folder>!<enter>'
        

2.1. System Email

Check and point enviroment mail variable to new local maildir;

        $ echo "MAIL=$HOME/.mail/" >> ~/.bashrc
        $ source ~/.bashrc
        $ env | grep MAIL
        

Content of .mutt/system;

        color status green default

        set folder="~/.mail"
        set mbox_type=Maildir
        set spoolfile=/var/spool/mail/machine-admin
        set keep_flagged=yes

        set mbox="~/.mail"           # ~/.mailext/read_inbox
        set postponed="+.Drafts"
        set record="+.Sent"

        set use_from=yes

        set sendmail=/usr/sbin/exim
        set ssl_starttls=no
        set ssl_force_tls=no

        unset pop_user
        unset pop_pass
        unset pop_delete
        unset pop_host
        unset smtp_url

        set realname='machine-admin'
        set from=machine-admin@localhost
        

Create folder;

        $ mkdir -p ~/.mail/{cur,new,tmp}
        

2.2. External Email

Edit .mutt/external;

        color status blue default

        unset sendmail

        set folder="~/.mailext"
        set mbox_type=Maildir
        set spoolfile="~/.mailext"
        set keep_flagged=yes            # esc-f to mark messages in spool, and

        set mbox="~/.mailext"
        set postponed="+.Drafts"
        set record="+.Sent"

        set use_from=yes
        set ssl_starttls=yes
        set ssl_force_tls = yes

        set realname='User Name'
        set from=mail@external.org

        set pop_user="mail@external.org"
        set pop_pass="password"
        set pop_delete=yes
        set pop_host="pops://$pop_user:$pop_pass@pop.external.org:995"

        set smtp_url="smtps://$pop_user:$pop_pass@smtp.external.org/"
        

Create folder;

        $ mkdir -p ~/.mailext/{cur,new,tmp}
        

3. Using Mutt

When listing messages the status flag mean;

s
if the message is signed and not yet verified
S
if the message is signed and the signature is successfully verified
P
if the message is PGP encrypted
        $ mutt
        /home/c1admin/.mail does not exist. Create it? ([yes]/no): yes
        

If you get the following error;

        /var/spool/mail/c1admin: No such file or directory (errno = 2)
        

Press q or x and lets send email to c1admin, this way we test if alias is working and exim create mail dir for us;

        $ mutt -s "test" c1admin@c13 < /dev/null
        

If you need to manually create a folder;

3.1. Tag Email

Just press shift-T and then read Patterns . After matching desired messages press ; then the order, for example, d will mark all taged for deletion.

3.2. Address alias

Alias makes easy to manage email addresses. Add this to your muttrc;

        source "~/.mutt/mail_alias"
        set alias_file=~/.mutt/mail_alias
        

While on index or page press "a" to add address to alias file.

3.3. GPG Keys

Import a public key from email;

        ^K
        

^K is CTRL+K

Tools Index

This is part of the Hive System Documentation. Copyright (C) 2018 Hive Team. See the file Gnu Free Documentation License for copying conditions.