Installation of MUTT in Dragora v2.2 (32 b)
This is a tutorial about the installation and configuration of the mail client mutt. Mutt is an application that requires the cooperation of other programs. In this case, the following combination has been chosen:
msmtp as SMTP client
vim as text interface
You can find all the information about mutt in http://www.mutt.org/.
1 Arranging a place in the system for mutt.
Along the following sections it will be described how to prepare your Dragora v2.2 operating system in order to make easier the installation of this addictive application.
The following operations are supposed to be performed in a root session. Letâs begin opening a folder in /opt to make a tidy and clean installation.
# mkdir /opt/MUTT
# cd /opt/MUTT
From now on, all the downloads will be done in /opt.
1.1 Building msmtp from source.
msmtp is an SMTP client. In the default mode, it transmits a mail to an SMTP server which takes care of further delivery.
See the details in msmtp.sourceforge.net
1.1.1 msmtp dependencies
msmtp requires the following libraries to enable its own functionality and some security features.
GnuTLS (gnutls)
The GnuTLS library provides TLS/SSL support. It is already installed within Dragora v2. (See /usr/include/gnutls)
GNU SASL (libgsasl)
Using the GNU SASL library adds support for the GSSAPI, DIGEST-MD5, SCRAM-SHA-1, and NTLM authentication methods. (The methods PLAIN, LOGIN, and CRAM-MD5 are always supported).
Without SASL an error during mutt runtime can occur; something like SMPT requires SASL.
All the information about this library can be found in https://www.gnu.org/software/gsasl/index.html.
Cyrus SASL2 (sasl2)
SASL (Simple Authentication Security Layer) is an Internet standards-track method for remote computers to authenticate. The Cyrus SASL library makes supporting various SASL mechanisms easy for both client and server writers.
Without the libraries included in sasl2 some errors can happen. One when trying to load the libraries themselves; a message like «no such file or directory» is displayed and mutt is stopped. In other occasions an error message can occur during mutt runtime, something like «failing a method to verify identity».
Here you can find more information. https://www.cyrusimap.org/docs/cyrus-sasl/2.1.25/.
See Annex VI for the complete list of library dependencies.
1.1.2 Checking the version of the installed libraries
With this command you can verify if the libraries have already been installed. Replace libname with libgnutls, libgsasl, or libplain (which is part of sasl2).
# ldconfig -v | grep libname
libgnutls.so.26 -> libgnutls.so.26.22.6
You should also try this to confirm if sas2 libraries are present in the operating system.
# whereis sasl2
libgsasl and sasl2 are not implemented in Dragora v2 by default, so maybe you will have to install them.
1.1.3 Installation of GNU SASL (libgsasl)
As the installation of the new library is going to be managed from the /opt directory, the following commands have to be run from a terminal opened in /opt.
Download
# wget -v ftp://ftp.gnu.org/gnu/gsasl/libgsasl-1.8.0.tar.*
Two files should be downloaded, the tar.gz file and its .sig signature.
Verification
# gpg libgsasl-1.8.0.tar.gz.sig
The purpose of this command is to obtain the GPG identification code, in this case B565716F. This code is needed in the next step.
# gpg --no-default-keyring --keyring vendors.gpg --keyserver pgp.mit.edu --recv-key B565716F
With this command the public key of the signature is imported from a key server.
# gpg --verify --keyring vendors.gpg libgsasl-1.8.0.tar.gz.sig
And finally, some information about the correct signatory should be displayed.
Installation
After these verifications, the tar.gz file has to be extracted.
# tar -xzvf libgsasl-1.8.0.tar.gz
# rm libgsasl-1.8.0.tar.*
We do not need them any more, so we can erase for the sake of tidiness.
And finally, the usual compiling process. The terminal to run the following commands has to be opened in the folder/opt/libgsasl-1.8.0/ .
# ./configure
# make
# make install
# make clean
It is interesting to have a look at the summary of the libraryâs building options, shown after configuring:
version: 1.8.0
Host type: i686-pc-linux-gnu
Install prefix: /usr/local
Compiler: cc: gcc cflags: -g -O2 cppflags:
Warning flags:
Library types: Shared=yes, Static=yes
Valgrind:
Obsolete functions: yes
Client side: yes
Server side: yes
ANONYMOUS: yes
EXTERNAL: yes
PLAIN: yes
LOGIN: yes
SECURID: yes
NTLM: no (libs: )
CRAM-MD5: yes
DIGEST-MD5: yes
SCRAM-SHA-1: yes
SAML20: yes
OPENID20: yes
GS2: no
GSSAPI: no
In this case the library has been installed in /usr/local, and authentication method called PLAIN has been enabled. This is the one precisely required by mutt.
1.1.4 Installation of the libraries Cyrus SASL2 (sasl2)
Letâs continue. Go to /opt/MUTT/ again.
Download
The following command have to be executed from a terminal opened in /opt.
# wget -v ftp://ftp.cyrusimap.org/cyrus-sasl/cyrus-sasl-2.1.26.tar.gz
There is no signature available in this case.
Installation
Then the file has to be extracted.
# tar -xzvf cyrus-sasl-2.1.26.tar.gz
# rm cyrus-sasl-2.1.26.tar.gz
# cd cyrus-sasl-2.1.26
The configuration process has to be performed in a terminal open in /opt/cyrus-sasl-2.1.26
By default the sasl2 libraries are installed in /usr/local/lib/sasl2/. But it is important, in order to avoid an error related with the authentication method, to use the --prefix=/usr. The sasl2 libraries must be located in /usr/lib.
# ./configure --prefix=/usr
# make
# make install
# make clean
It is interesting to update the relations among the libraries.
# ldconfig
You can also verify if sasl2 have been correctly installed in their place.
# whereis sasl2
sasl2: /usr/lib/sasl2
All these shared objects and libtools files should be present.
# cd /usr/lib/sasl2; ls
libanonymous.la libdigestmd5.so.3 libsasldb.la
libanonymous.so libdigestmd5.so.3.0.0 libsasldb.so
libanonymous.so.3 libotp.la libsasldb.so.3
libanonymous.so.3.0.0 libotp.so libsasldb.so.3.0.0
libcrammd5.la libotp.so.3 libscram.la
libcrammd5.so libotp.so.3.0.0 libscram.so
libcrammd5.so.3 libplain.la libscram.so.3
libcrammd5.so.3.0.0 libplain.so libscram.so.3.0.0
libdigestmd5.la libplain.so.3
libdigestmd5.so libplain.so.3.0.0
1.1.5 Configuring msmtp
Download
# wget -v http://downloads.sourceforge.net/project/msmtp/msmtp/1.6.5/msmtp-1.6.5.tar.xz
# wget -v http://downloads.sourceforge.net/project/msmtp/msmtp/1.6.5/msmtp-1.6.5.tar.xz.sig
There is a little problem because it is not immediate to get signatures or sha1sums to verify the integrity of the package. In other browsers the sha1sum appears as hidden feature shown in âview detailsâ, but it does not appear in older IceCat versions. You can find the sums in the next paragraphs.
Verification (Sha1sums)
# sha1sum msmtp-1.6.5.tar.xz
27d1fc609cd453a7e4c55c4ec55d455949bc53f1 msmtp-1.6.5.tar.xz
It is also possible to check the sha1sum integrity of the signature.
# sha1sum msmtp-1.6.5.tar.xz.sig
c7af4d6b4e136a03564704246e594cf9712f67d5 msmtp-1.6.5.tar.xz.sig
According to the information in web page, those sha1sum are correct.
Verification (gpg signature)
# gpg msmtp-1.6.5.tar.xz.sig
This line is to get the GPG identification code, in this case 95E5294. This code is needed in the next step.
# gpg --no-default-keyring --keyring vendors.gpg --keyserver pgp.mit.edu --recv-key 953E5294
With this command the public key of the signature is imported from a key server.
# gpg --verify --verbose --keyring vendors.gpg msmtp-1.6.5.tar.xz.sig
And finally, some information about signatory should be displayed. In this case Martin Lambers <address@hidden>.
# tar -xvf msmtp-1.6.5.tar.xz
# rm msmtp-1.6.5.tar.xz.*
Note: if you do not have XZ-Utils installed see Annex V. You will need it to extract .xz tar files.
1.1.6 Installing msmstp
# ./configure
This information is shown at the end of the ./configure process.
Install prefix ......... : /usr/local
TLS/SSL support ........ : yes (Library: GnuTLS)
GNU SASL support ....... : no (before installing GNU SASL)
GNU SASL support ....... : yes
IDN support ............ : yes (via GNU Libidn)
NLS support ............ : yes
Libsecret support (GNOME): no
MacOS X Keychain support : no
# make
# make install
# make clean
It is important to have a look on the information offered by the version argument of msmtp. It informs about the expected location of the configuration files msmtprc and .msmtprc.
# msmtp --version
msmtp version 1.6.5
Platform: i686-pc-linux-gnu
TLS/SSL library: GnuTLS
Authentication library: built-in (before installing GNU SASL)
Authentication library: GNU SASL
Supported authentication methods:
plain scram-sha-1 external cram-md5 digest-md5 login
IDN support: enabled
NLS: enabled, LOCALEDIR is /usr/local/share/locale
Keyring support: none
System configuration file name: /usr/local/etc/msmtprc
User configuration file name: /root/.msmtprc
Copyright (C) 2016 Martin Lambers and others.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law
1.1.7 Creating msmtprc configuration files
/root/.msmtprc
You have to create a file called .msmtprc. See Annex I for an example, and do not forget to adapt it with your own smtp server data.
It is recommended to change the permissions of the file, otherwise msmtprc will fail.
# chmod --verbose 600 .msmtprc
Some information about changes is displayed, like 0755 (rwxr-xr-x) to 0600 (rw-------)
/usr/local/etc/msmtprc
You have to create the msmtprc file. It is possible to use the same content for this file than in .msmtprc.
/var/log/msmtp.log
Create an empty file in plain text called msmtp.log.
/etc/logrotate.d/msmtp
A possible content of the msmtp file in logrotate.d could be:

/var/log/msmtp.log {
rotate 12
monthly
compress
missingok
notifempty
}
/etc/ssl/certs/ca-certificates.crt
It is necessary to create ca-certificates.cr.
In some rare occasions the following error message has been reported:
msmtp: cannot set X509 trust file /etc/ssl/certs/ca-certificates.crt for TLS session: Error while reading file.
msmtp: could not send mail (account default from /root/.msmtprc)
It can be fixed using a previously existing file, for example one associated to the use of gmail.
1.2 Preparing folders and configuration files for mutt.
1.2.1 Configuration file Muttrc. (SYSCONFDIR)
The path to this file is /usr/local/etc/Muttrc. It is important to preserve the capital «M».
See Annex II for a proposed file.
1.2.2 Other settings (MAILPATH)
The next steps consist in creating new folders and configuration files.
/var/spool/mail/
It is required to create the folder /mail and an empty file called root .
It is also necessary to create the following folders:
/etc/mutt/cache/bodies
/etc/mutt/cache/headers
Depending on some configuration variables the headers folder could be used or not, but anyway, it could be a default setting.
/etc/mutt/
And finally, create another empty the file called certificates .
1.3 Settings for vim, to enable auto spelling
By default, the installed version in Dragora V2 can be checked by using:
# vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 18 2012 20:10:14)
It also shows important information about the configuring files. Among others:
file "vimrc" of the system: "$VIM/vimrc"
file "vimrc" of the user: "$HOME/.vimrc"
The next step will configure vimrc to support the spelling functionality. Search the file vimrc:
# whereis vimrc
vimrc: /etc/vimrc
And edit it with your favorite text editor in order to add the following code.
set spelllang=es,en
map <f12> :set spell!<cr>
"this is to activate/deactivate the spelling
You should choose your language, of course. It is possible to select several languages, and all of them will be checked at the same time! (Try mixing words in different languages; vim will recognize them and check the correct spelling)
See Annex IV for some basics instructions to handle vim.
It is necessary to link vim with mutt thru the Muttrc file, by adding this line:
set editor="vim -c 'set spell spelllang=es,en'"
Note: If you do not feel comfortable with vim, do not add that line, and mutt will use the default text editor, moe. But the default version of moe does not support auto spelling.
And also be sure that you choose the appropriate language. You will also need the dictionary files for auto spelling. They should be somewhere around:
/usr/share/vim/vim73/spell/
Depending on the installed version of vim the path would be .../vim74/... You can gess it with vim --version.
The dictionary files can be downloaded from http://ftp.vim.org/vim/runtime/spell/. There are a lot of xx.latin1.spl or xx.utf-8.spl etc. A bundle of files that works fine for Spanish and English spelling is:
en.ascii.spl en.latin1.spl en.utf-8.spl es.latin1.spl en.ascii.sug
en.latin1.sug en.utf-8.sug es.utf-8.spl
2 Download and security checks of mutt
# wget -v ftp://ftp.mutt.org/pub/mutt/mutt-1.6.1.tar.*
# gpg mutt-1.6.1.tar.gz.asc
This line is to get the GPG identification code, in this case 80316BDA. This code is needed in the next step.
# gpg --no-default-keyring --keyring vendors.gpg --keyserver pgp.mit.edu --recv-key 80316BDA
With this command the public key of the signature is imported from a key server.
# gpg --verify --verbose --keyring vendors.gpg mutt-1.6.1.tar.gz.asc
And finally, some information about correct signatory should be displayed. In this case is signed by Kevin J. McCarthy <address@hidden>.
# tar -xvf mutt-1.6.1.tar.gz
# rm mutt-1.6.1.tar.*
3 Finally, building mutt from source
Do not forget to go into mutt-1.6.1 directory to run the following command:
./configure --enable-imap --enable-smtp --enable-debug --with-ssl --with-gnutls --with-sasl SENDMAIL="/usr/local/bin/msmtp"
The option --enable-debug is interesting to find out possible errors, and allows the following running options:
# mutt -D
Print the value of all variables to stdout
# mutt-d <level>
Log debugging output to ~/.muttdebug0. <level> takes integer values between 0 to 3 both included.
And finally:
# make && make install && make clean
See also the See Annex VI for the complete list of library dependencies.
4 GnuPG signature
If you have a GPG key it is possible to sign your mails. See Annex I, look for the nice bunch of set gpg sentences, uncomment them and customize set pgp_sign_as= with your own public key ID.
5 Simple signature
Just place a plain text file my_signature, for example in /usr/local/etc/. Do not forget to tell mutt where to find it by adding this line in Muttrc: set signature="/usr/local/etc/my_signature"
See Annex III for an example.
6 GNU Licenses.
This is important if you are interested in  having freedom in your computer.
mutt 1.6.1:GNU GENERAL PUBLIC LICENSE Version 2, June 1991
msmstp 1.6.5: GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
libgsasl-1.8.0:GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
cyrus-sasl-2.1.26: The license is not GLP, but redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met...Anyway this license is similar to the BSD, so it can be considered free software.
vim: The license is GPL-compatible
ANNEX I. msmtprc and .msmtprc settings file
defaults
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
tls_certcheck on
account default
host smtp.gmail.com
port 587
auth on
user address@hidden
password YOURPASSWORD
from address@hidden
logfile /var/log/msmtp.log
ANNEX II. Muttrc settings file
# headers
ignore *
unignore Date From To CC List-ID Subject Reply-to
hdr_order Date From To CC List-ID Subject Reply-to
# wonderful. If not, the whole header appears in an
# unfriendly human style. Too much information.
#scroll inside the message rather than the index
# Even more wonderful. If not, the only default scroll is
# with space bar or -, but the whole page scrolls up or down.
bind pager <up> previous-line
bind pager <down> next-line
#===========GMAIL =================================
set from = "address@hidden"
set realname = "your name"
set imap_user = "address@hidden"
set imap_pass = "your pass (optional)"
set ssl_starttls=yes
set ssl_force_tls=yes
bind index G imap-fetch-mail
#Pressing G will refresh the mail
#========== Remote Gmail Folders==============================
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed = "+[Gmail]/Drafts"
# set trash = "+[Gmail]/Trash"
#========== SMTP Settings to sent email ==========================
set smtp_url = "smtps://address@hidden@smtp.gmail.com:465"
set smtp_pass = "your pass (optional)"
#===== Local folders for cached headers and certificates ==================
#set header_cache = /etc/mutt/cache/headers
set message_cachedir = /etc/mutt/cache/bodies
set certificate_file = /etc/mutt/certificates
# ===== Security features =========================================
set move = no
set imap_keepalive = 900
#====== Mail sorting ===========================================
set sort = reverse-threads
set sort_aux = last-date-received
set indent_string="> "
#==========Sendmail =========================================
set sendmail="/usr/local/bin/msmtp"
# ==== Colors, call me classic ====================================
color attachment brightmagenta default
color error brightgreen default
color hdrdefault green default
color indicator brightyellow green
color markers brightcyan default
color message brightcyan default
color normal brightgreen default
color quoted brightblue default
color search default green
color signature green default
color status black white
color tilde magenta default
color tree magenta default
#======================================================================
#------------- INTERACTION with GnuPG ----------------------------------
#set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f"
#set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
#set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
#set pgp_import_command="gpg --no-verbose --import -v %f"
#set pgp_export_command="gpg --no-verbose --export --armor %r"
#set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r"
#set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r"
#set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r"
#set pgp_autosign=yes
#set pgp_sign_as=YOUROWNKEY
#set pgp_timeout=1800
#set pgp_good_sign="^gpg: Good signature from"
#=======================================================================
#-------------- TEXT EDITOR and AUTO SPELLING --------------------------------------------------------
set editor="vim -c 'set spell spelllang=es,en'"
#Check for your language
#=======================================================================
#----------------- normal signature ----------------------------------------------------------------------------------------
set signature="/usr/local/etc/yourfile"
#Donât forget to change it with your signature file
ANNEX III. An example of signature file
--------------------------
Gordon Shumway
GPG pub ID = EXXXXXX
ANNEX IV. Some basic instructions and commands for VIM
Ins: To begin writing the body of the mail.
Ctrl + C: To exit the body of the mail. This is necessary for telling vim to save changes, quit or for enabling the spelling function (F12). It is also necessary for using the «letter» commands, like:
dd, to delete a line
u, to undo the last action
Copy, cut and paste.
See vim.wikia.com/wiki/Copy,_cut_and_paste
The first mail with mutt + vim.
# mutt
write your password
Press Shift + G to refresh the mail
Press m to write an email
(Bottom line): Write the address
(Bottom line): Write the subject
(In VIM).
Press ins to begin to write (Hello world, of course)
Ctrl + C to exit the body
(VIM bottom line) F12 to enable / disable spelling highlights
Press ins to return to the body of the email and write again
Ctrl + C to finish
(VIM bottom line) :wq (to save and return to mutt)
(in Mutt) press y to send the mail.
(Bottom line). Write your GPG phrase (if you have one)
Press q to exit Mutt.
And thatâs all.
ANNEX V. XZ UTILS
Installation of XZ Utils, needed to extract .tar.xz files.
#wget -v http://tukaani.org/xz/xz-5.2.2.tar.gz
#wget -v http://tukaani.org/xz/xz-5.2.2.tar.gz.sig
# gpg --no-default-keyring --keyring vendors.gpg --keyserver pgp.mit.edu --recv-key 69184620
# gpg --verify --verbose --keyring vendors.gpg xz-5.2.2.tar.gz.sig
# tar -xvf xz-5.2.2.tar.gz
# rm xz-5.2.2.tar.*
# cd xz-5.2.2
# ./configure && make && make install && make clean && ldconfig
ANNEX VI. XZ List of dependencies
Dependencies of msmtp
linux-gate *
libgnutls
libgsasl
libidn *
libc *
libnettle
libgmp
libhogweed
libz
libpthread
libgcrypt
libgpg-error
Dependencies of mutt
linux-gate *
libncursesw
libssl
libcrypto
libz *
libsasl2
libidn*
libc *
libdl
libresolv
* common dependency msmtp - mutt