[mutt] Configure mutt to receive email via IMAP and send via SMTP

Tags

, , , , , , , , , , ,

“All mail clients suck. This one [mutt] just sucks less.” Michael Elkins, ca. 1995

Actually I have tried a lot of desktop email clients (viz., Outlook, thunderbird, seamonkey, sylpheed, pine, alpine, claws email, kmail, evolution, opera) and in the long run they all starts sucking at the RAM. Now to be precise, I must tell you that it’s not a full-fledged mail-transfer agent (MTA), but rather a mail user agent (MUA), i.e. just an email client just like those previously mentioned.

Step 1: Create a password file, say ~/.secret/.passwd. Enter the passwords in it as follows and save the file (don’t worry, we’re going to encrypt it soon!):

GMail:    passwd1
Yahoo:    passwd2

Step 2: Now encrypt the file with your gpg key (refer to the previous post for details). Don’t forget to delete the unencrypted file.

$ cd ~/.secret
$ gpg -e .passwd -o .passwd.gpg
$ rm -f .passwd

Step 3a: back to the home direcotory and modify the ~/.muttrc file: (you may equivalently do the same in ~/.mutt/muttrc)

# Process the password files first
#-------------------------------------
set my_tmpsecret=`gpg -o ~/.secret/.tmp -d ~/.secret/.passwd.gpg`
set my_gpass=`awk '/GMail:/ {print $2}' ~/.secret/.tmp`
set my_ypass=`awk '/Yahoo:/ {print $2}' ~/.secret/.tmp`
set my_del=`rm -f ~/.secret/.tmp`

Note: All user-defined variable must start with “my_”.

Step 3b: Now set up mutt for IMAP: (let’s say for GMail)

set imap_user="gmail.username@gmail.com"
set imap_pass=$my_gpass
set folder="imaps://gmail.username@imap.gmail.com:993/"
set spoolfile="+INBOX"
set postponed="+[Gmail]/Drafts"
set record=+[Gmail]/"Sent Mail"

Step 3c: Now let’s say we want to use Yahoo’s SMTP service to send emails: here’s how to set it up in ~/.muttrc:

set smtp_pass=$my_ypass
set smtp_url = "smtp://smtp.yahoo.com:587"  # using port 587 for TLS
set from="yahoo_username@yahoo.com"
set realname="Your Real_Name"

Step 3d: Set your favorite editor to compose emails next in ~/.muttrc (mine is vim, so….)

set editor='vim + -c "set textwidth=72" -c "set wrap" -c "set nocp" -c "?^$"'

Step 3e: Other necessary things to put in ~/.muttrc:

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

Step 3f: Now time for some pretty color: (add these too to ~/.muttrc)

color  body            brightyellow    black    (((ht|f)tps?)|mailto):(//)?[^\ "\t]*|www\.[-a-z0-9.]+)[^\ .,;\t>">]
mono   body            bold                     (((ht|f)tps?)|mailto):(//)?[^\ "\t]*|www\.[-a-z0-9.]+)[^\ .,;\t>">]
color  body            brightmagenta   black   "[-a-z_0-9.]+@[-a-z_0-9.]+"
mono   body            bold                    "[-a-z_0-9.]+@[-a-z_0-9.]+"
color  body            brightyellow    black   "^Good signature"
mono   body            bold                    "^Good signature"
color  body            brightwhite     red     "^Bad signature from.*"
mono   body            bold                    "^Bad signature from.*"

Step 3g: Some other customizations to put in ~/.muttrc:

set smart_wrap = yes
set sort = 'threads'
set sort_aux = 'last-date-received'
set imap_check_subscribed
#
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc
#
set timeout=60	#Check for mail every minute
set mail_check=5

Step 3h: Now save the file in your home directory and make it readable by none but the current user (you of course!):

$ chmod 700 ~/.muttrc

Step 4:Next create the these two directories to save mutt related stuffs:

$ mkdir .mutt
$ mkdir .mutt/cache

Step 5:To render the HTML/etc messages correctly create another file ~/.mailcap with the following as its content make it readable by you only (use chmod as above)

text/html; lynx -dump %s ; copiousoutput

Change lynx to links/links2/elinks depending what you actually have on your system.

Things to do:
I still cannot use multiple IMAP inboxes at a time — the account-hook / folder-hook does not seem to work. I need to spend some more time on it.

Here’s how to use multiple IMAP accounts in mutt.

References for this post: Crunchbang Linux site (my latest favorite distro!), muttrc builder, and mutt.org, of course. Another old reference from the days when mutt wouldn’t do SMTP. Also look at the references at the end of this wikipedia page. To build mutt from the source, refer to this.

References for to-do: Derkeller and mutt-users forum (from 2002!).

[osx] Fix PDF font display problem on Leopard

Tags

, , , ,

If Preview or Skim stops showing current fonts/ symbols in a PDF document on your Mac, you may need to kill ATSServer process to fix this problem:

$ killall -u <username> ATSServer

[osx] Do not let Safari open PDF files by itself — use an external viewer

Tags

, , , , , , , , , ,

Safari (4.0.4) shows PDFs in the browser window by default when you click on a hyperlink to a PDF file. What is happening here is that when you click on the link, Safari downloads the file in the /tmp directory and opens it by itself. I don’t want that — I want to open it in a stand-alone PDF viewer, say Skim, which will allow me to do other PDF-related stuff (e.g. annotation). A command line trick will do the job (enter the following command after the prompt, indicated by $ here, in the terminal):

$ defaults write com.apple.Safari WebKitOmitPDFSupport -bool YES

If you want to go back to the default behavior use the same command but change ‘YES’ to ‘NO’.

NOTE: You may run across a totally different issue which will force you to view a PDF file in the browser window if you have Adobe reader plugin installed. In that case just remove that plugin from the following directories:
/Library/"Internet Plug-Ins"
~/Library/"Internet Plug-Ins"

I have tested this on Mac OSX  – Leopard (10.5.8).

Credit: Mac Rumors forum.

[cli] Delete a file whose name starts with a dash

Tags

, , , ,

Some badly formatted command may lead to a filename with a leading dash in its name, e.g. -bad_file. To delete this file in the command line either of the following commands should be enough:

$ rm -- -bad_file

OR

$ rm ./-bad_file

But if the filename is just a dash (-), things may get a little tricky. Follow the steps 1–3 to delete a file named as “ – ”:

[you may use this method to delete the first file, -bad_file as well]

1. Find the inode numbers first. The following command will print the file serial number (inode number)  for each file in the working directory:

$ ls -li

2. Then check to see if the inode number (say, 12345) of the culprit, viz. “  – ”,   corresponds to it correctly (optional step):

$ find . -inum 12345

3. If it finds the name of the `culprit’ correctly, which it should if the number is correct, proceed  to remove it:

$ find . -inum 12345 -exec rm {} \;

That’s it!

Credit: here.

[osx] Force Safari to open links in a new tab instead of a new window

Tags

, , , , ,

In my Macbook (Lepard: OSX  version 10.5.8), Safari (version 4.0.4) in general opens a new link in a new window instead of a new tab if the link has target="_blank" attribute. It just gets in my way of organizing things.

To force the link open in a new tab use the following command (without my favorite prompt sign “$”) in the terminal and restart Safari:

$ defaults write com.apple.Safari TargetedClicksCreateTabs -bool true

Notes: 1. This will open the link in the foreground. Command+click will however open the link the background (even without the above trick).

2. Change `true’ to `false’ to revert back to the default behavior.

Credit: MacOSX hints.

Design a site like this with WordPress.com
Get started