Install + Config mutt-sidebar

Hello everyone !

Lets make mutt more intersting by adding sidebar in mutt. Install it

For ubuntu
$ sudo apt-get install mutt-patched
For Arch
$ sudo pacman -S package-query yaourt
$ sudo yaourt -S mutt-sidebar

Add following to your .muttrc file and make changes accordingly.

#change width accordingly
set sidebar_width=30

#Visible at first, then change its value to yes
set sidebar_visible=no

set sidebar_delim='|'
set sidebar_sort=yes
mailboxes =inbox =ml
mailboxes =inbox =ml
bind index CP sidebar-prev
bind index CN sidebar-next
bind index CO sidebar-open
bind pager CP sidebar-prev
bind pager CN sidebar-next
bind pager CO sidebar-open
macro index b '<enter-command>toggle sidebar_visible<enter>'
macro pager b '<enter-command>toggle sidebar_visible<enter>'
bind index B bounce-message

Shortcuts to use

CP = Previous folder in sidebar
CN = Next folder in sidebar
CO = Open Selected folder in sidebar
b = toggle sidebar

If you want to change shortcuts, then change the values in .muttrc file accordingly.
Enjoy your new mutt sidebar. 😛

xterm : enable 256 color support on : xterm-256color

You might need 256 bit color support in your various terminal applications like vim, mutt, mplayer, htop and others. Below are the instructions to enable 256 bit color support.

Pretty quick, issue command in your terminal

$ export TERM=xterm-256color

To make it permanant, add the same to your .bashrc or .zshrc file, according to the shell you’re using.
Test the output with

(x=`tput op` y=`printf %76s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done)

That’s it, enjoy colors !

MUTT : Background sending with mSMTP

I am regular mutt user. Here is a good fix to remove waiting while the mutt interacts with the SMTP server to send an email. Previously I used a local mail server, now I am going to use mSMTP which is a SMTP Client just like mutt. We will let the mSMTP do the sending part in the background and will keep reading mails in the mutt, Sounds cool, eh ?

At First, Do Install and Configure mSMTP, don’t worry its a quick one.

Open your .muttrc file, remove smtp_url variable, or comment it.

#set smtp_url = "smtp://vigas@csiom.com@csiom.com"

Append following, change things accordingly.

#sets path to msmtp command
set sendmail="/usr/bin/msmtp"
set envelope_from=yes

#Tells mSMTP to use which block of address to send the email
macro generic "1" ":set from=email@gmail.com"

#Background sending, Hurray !
set sendmail_wait=-1

That’s it guys !

Feel free to share problems, if any. I’ll be back after some sleep.

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 !

Troubleshoot Huawei E398 On Manjaro Linux

Its been days, my Tata Photon Plus device, E398 was not working properly on my favourite linux distro, Manjaro. So today I found some time to dig it and solve the problem.

Problem was that, My modem was showing up lsusb but was not getting detected by wvdial or dmesg.

$ lsusb
Bus 002 Device 009: ID 12d1:1505 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard

First of all, install following packages.

Here, note down following.
Vendor ID = 12d1
Product ID = 1505

Now install these packages.


# pacman -S usb_modeswitch modemmanager wvdial ppp

Edit this file after installing the packages


vim /lib/udev/rules.d/40-usb_modeswitch.rules

Append following lines at the end, and replace Vendor ID and Product ID accordingly.

#Huawei E398
ATTR{idVendor}=="12d1", ATTR{idProduct}=="1505", RUN+="usb_modeswitch '%b/%k'"

Issue following command to test

# usb_modeswitch -v 12d1 -p 1505 -V 12d1 -P 1506 -M "55534243123456780000000000000011062000000100000000000000000000" 

If everything goes right issue this command using your product and vendor ID.

modprobe option vendor=0x12d1 product=0x1506

Replug the Modem, It will work like a charm. Keep me posted if you face any problems.

Cheers !

Installing Gnome 3.10 on Ubuntu 13.10 (Saucy) Final Beta

Gnome 3.10

Want to spice up your desktop by installing the crisp of new Gnome shell ?

Gnome 3.10
Gnome 3.10


Gnome 3.10 is the major release after 3.8, which includes various performace + UI improvements. It also have various extensions already installed as well as “Tweak Tool” is also pre-installed. Use following commands to install Gnome 3.10 on Ubuntu 13.10 Final Beta.

Open Terminal :

sudo add-apt-repository ppa:gnome3-team/gnome3-next

sudo apt-get update

sudo apt-get install gnome-shell ubuntu-gnome-desktop

Install it and have some fun 😉

Setting up openDKIM with Postfix (+ Troubleshooting)

Introduction

DomainKeys Identified Mail, abbreviated as DKIM. It is a protocol which ensures that, the emails received are from right and authentic senders, and are not forged. DKIM uses public key cryptography [wiki link]. Most of the times when you deal with a mail server, emails are unfortunately going into spam, because your DNS does not have a DomainKey record, which authenticates the emails coming from your domain.

Requirements

  1. I assume you are familiar with Debian based distrubution.
  2. You are having postfix mail server, this guide deals with postfix only.
  3. You have knowledge of basic linux commands

Installation

You can simply issue issue the following command to install openDKIM.

sudo aptitude install opendkim opendkim-tools dkim-filter

Configuration

Two configuration files of DKIM.

/etc/opendkim.conf
/etc/default/opendkim 
/etc/default/dkim-filter

Firstly edit, /etc/opendkim.conf , Make sure your file do have these. Just edit “Domain” and “Selector”.


Domain                  vigasdeep.com #Use your domain here
KeyFile                 /etc/mail/dkim.key # We will generate this key later on
Selector                mail #this can be anything

# DomainKey is combined with "Selector" and "Domain", including an extra string "_domainkey"
# For Example mail._domainkey.vigasdeep.com

# Common settings. See dkim-filter.conf(5) for more information.
AutoRestart             yes
Background              yes
Canonicalization        relaxed/relaxed
DNSTimeout              5
Mode                    sv
SignatureAlgorithm      rsa-sha256
SubDomains              no
X-Header                no

After that, edit /etc/default/dkim-filter and make sure it have following

DAEMON_OPTS="-l -o DKIM-Signature,X-DKIM"
DAEMON_OPTS="$DAEMON_OPTS -d vigasdeep.com -k /etc/mail/dkim.key -s mail"
SOCKET="inet:8891@localhost"

Now we’ll edit /etc/postfix/main.cf file. Append following text into the file.

# DKIM
milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891

Thats all for the Configuration.

Generate Public/Private key for DKIM

This command with generate a public/private key pair. Replace “mail” with your own selector, and “vigasdeep.com” with your domain name.

opendkim-genkey -t -s mail -d vigasdeep.com

After this, place the private key to its right place at /etc/mail/dkim.key

cp mail.private /etc/mail/dkim.key  
# here <strong>mail</strong> refers to the selector

Thats it.

Optionally, you can also create a public/private key pair from http://dkimcore.org/tools/. Change Selector accordingly into /etc/opendkim.conf file.

If you have generated the keys on the web, then create a new file /etc/mail/dkim.key and paste private key into it.

Adding DNS (txt record) for domainkey

Adding the DNS entry is the most crucial part, please be patient and read carefully. When you created public/private key pair. Use public key for DNS entry. Login to your domain’s control panel, change DNS Settings, and add a TXT record. TXT record will ask you for two things. Host and Data.

Host will be ( change accordingly for your case )

mail._domainkey.vigasdeep.com
## [Selector]._domainkey.[domain.com]

and data would be something like

"v=DKIM1;=rsa; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8O7fJSx/nbZfzy75pfMnSO57Y0/xyIQQfrWUFwo2PXIamDSII7KB83u0MBeSrt1TPAnSmcRlKIurEBD8xF1Um8cnM/D2W5BlPqKTiII9CHLNEiCKYJiG1EuB+5Wl47UCHnmRaX3+PrbB/r1AWEmT+8cNbz4FW60mQaEIHBFsgwIDAQAB"

Add the entry, and you’re done. Now we will test it out.

Starting DKIM and Troubleshooting

sudo service opendkim start

If you’re not able to send email, probably there is something wrong with the configuration. Check the mail logs.

grep -i dkim /var/log/mail.log

Check if DKIM is working correctly at http://dkimcore.org/tools/keycheck.html

Facing problems ? Post comment Or Hire me, I’ll be back after my “Double-Tikki” Burger. Hah !