Installing and Configuring mSMTP

mSMTP is an SMTP client which can be used with various applications and scripts such as Mutt, Php, Python etc

Remember, we will do everything as a sudo user and NOT root.

Install the msmtp and ca-certificates packages.

For Arch
$ sudo pacman -S msmtp ca-certificates
For Debian/Ubuntu
$ sudo apt-get install msmtp ca-certificates
For Fedora/Rhel/CentOS
$ sudo yum install msmtp ca-certificates

Create a new .msmtprc file in your home directory and open it with your favourite editor. VIM neerds alert! (If you don’t know what this means, never mind. Just open the file.)

$ vim ~/.msmtmrc

Copy following text into the .msmtprc file. If you have only one email ID, keep the default section, if you have more then two, add more accordingly.

account default
host smtp.gmail.com
from email@youremailhost.com
auth on
port 587
user email@gmail.com
password MySecret
logfile ~/.msmtp.log
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt


account custom
tls off
tls_starttls off
host smtp.youremailhost.com
from email@youremailhost.com
auth yes 
port 25
user email@youremailhost.com
passwordeval gpg -q --for-your-eyes-only --no-tty -d .mutt/.pass.gpg | awk '/email@youremailhost.com:/ {print $2}'
logfile ~/.msmtp.log

As you can see I have two examples one with simple password and one with encrypted password. You can use password variable for basic use, as used for default account in .msmtprc file. If you don’t want your friends to see your password, who use your computer, and more specifically your user, then you should definately use passwordeval variable. passwordeval variable tells the msmtp to fetch password from an encryped gpg file. More details on Encrypting password in with GnuPG, of course you need to see what you want from that link.

Test your configuration with following command

echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=default -t username@gmail.com

It probably won’t work 😉 Change permissions of .msmtprc file then.

chmod 600 .msmtprc

Doesn’t work? Apply common sense!

Still not working? poke me !

MUTT – encrypting password with GNUpg

To encrypt password with mutt, we will be using GNUpg, install it :

For Debian based : $ sudo apt-get install gnupg gnupg-agent
For RPM based : $ sudo yum install gnupg gnupg-agent

after installing it you need to generate an encryption key by using following.

gpg --gen-key

Select appropriate options. Enter you name, email and passphare when it asks. Do not forget your passphrase.
now create a file .pass place it in your home folder, I am placing it here :

touch ~/.mutt/.pass

contents fo following file should be :

GMail:<use tab>mySecretPassowrd

encrypt it by using:

cd ~/.mutt
gpg --encrypt .pass

Now you will see a file is created as .pass.gpg , if it is there, you can delete orignal .pass file. After this step you have to make changes to .muttrc file. Append the following by doing appropriate changes

set imap_pass = `gpg -d ~/.mutt/.pass.gpg | awk '/GMail:/ {print $2}'`

NOTE : if imap_pass and smtp_pass are defined anywhere else, you have to remove them or comment those two lines like this :

#<s>set imap_pass = ""</s>
#<s>set smtp_pass = ""</s>

Thats it, now you can start mutt and it will ask the passphrase for your key, and will never irritate you again 🙂
Good Luck.

MUTT – The Ultimate Mailing Client

Mutt is a small but very powerful text-based mail client for Unix operating systems. The current stable public release version is 1.4.2.3; the current development release version is 1.5.21. For more information, refer : http://mutt.org

First of all,

Download Needed files.

Next, Installing Mutt.

for Debian based : $ sudo apt-get install mutt urlview
for RPM based : $ sudo yum install mutt urlview

Thats it, mutt is installed, next you need to have a .muttrc configuration file now. Firstly execute following commands :

$ mkdir ~/.mutt
$ mkdir ~/.mutt/cache
$ mkdir ~/.mutt/cache/{bodies,headers}
$ touch ~/.mutt/certificates

Now look for muttrc file in the tar.gz archive, make changes according to your user,password and set your favourite editor to to compose messages. Place this file into your home directory and rename to .muttrc . Now you’re done, start mutt with :

$ mutt

Basic usage :

enter : To open a message and scroll down in a message
i : To get back to all messages screen
backspace : To scroll up in a message
r : To reply a message
m : To compose
y : To send composed email
left arrow : To go to previous message in reading screen
right arrow : To go to next message in reading screen
c then ? : To go to gmail folder list

That all for now, use “?” at any screen for help menu. Let your mouse, have some sleep ;-).

All email clients suck, this one just sucks less ~ Mutt.
Happy Mutting !