HOWTO: Using heirloom-mailx with Gmail

Share your own howto's etc. Not for support questions!

HOWTO: Using heirloom-mailx with Gmail

Postby MrFrood » 2013-04-14 23:42

I am assuming that you have already enabled IMAP access for your Gmail

Debian offers two versions of mailx
1: bsd-mailx
2: heirloom-mailx

bsd-mailx is the default so the first thing we need to do is install heirloom-mailx. A the same time we will also install elinks as this will be used to help view html emails.

As root run either of the following command (feel free to use apt if you are more comfortable using it)
Code: Select all
aptitude install heirloom-mailx elinks

Now we need to configure heirloom-mailx by writing a .mailrc file to the users home directory. Options within account gmail {...} will only apply when invoking heirloom-mailx with the -A flag to use the gmail account. All the options listed below are fully documented in the heirloom-mailx man page.

Copy the sample .mailrc below to ~/.mailrc changing the Gmail username and password to yours and user to the name of the Debian user that will be using heirloom-mailx.
Code: Select all
account gmail {
   set folder=imaps://
   set imap-use-starttls
   set nss-config-dir=/home/user/.mozilla/firefox/xxxxxxxx.default
   set record=+[Google\ Mail]/Sent\ Mail
   set from="Your Name <>"
   set replyto=""
   set sender=""
        set smtp-auth-password="password"
   set smtp-use-starttls
   set smtp=""
   set smtp-auth="login"

# IMAP SHORTCUTS SECTION for standard Gmail folders
   shortcut allmail +[Google\ Mail]/All\ Mail
   shortcut in +INBOX
   shortcut spam +[Google\ Mail]/Spam
   shortcut trash +[Google\ Mail]/Bin
   shortcut sent +[Google\ Mail]/Sent\ Mail

# Binary options
set askattach
set autoinc
set autothread
set bsdannounce
set bsdflags
set bsdheadline
set bsdmsgs
set bsdorder
set datefield
set dot
set editheaders
set emptystart
set fullnames
set hold
set keep
set markanswered
set print-alternatives
set quiet
set reply-in-same-charset
set showlast
set showname
set showto

# String Options
fwdretain subject date from to
ignore received in-reply-to message-id references
ignore mime-version content-transfer-encoding
retain subject date from to cc x-mailer user-agent mail-system-version mailer originating-client x-newsreader x-mimeole message-id list-id
set autosort=thread
set contenttype-cntrl=text/plain
set crt=20
set encoding=quoted-printable
set headline="%>%a%m %27f  %24d %4l/%-5o %i%S"
set imap-keepalive=240
set imap-list-depth=5
set indentprefix="> "
set newmail=nopoll
set pipe-text/plain="fold -s | less"
set prompt="& "
set quote=headers
set sendcharsets=iso-8859-1,iso-8859-15,utf-8
set signature=/home/user/.signature

# Reading HTML mail
set pipe-text/html="elinks -dump -dump-charset utf-8 -default-mime-type text/html /dev/stdin"

# Address Book
alias  friend1

Depending on where you are in the world you may need to change
Code: Select all
[Google\ Mail]
Code: Select all

In the line
Code: Select all
set nss-config-dir=/home/user/.mozilla/firefox/xxxxxxxx.default
you will need to change "xxxxxxxx" to whatever it is called on your computer.

All you should need to do now is invoke mailx with the command
Code: Select all
mailx -A gmail

The heirlooom-mailx man page is well written and contains a detailed list of commands for using the program and the options used in the .mailrc above. The options in the sample .mailrc above are ones that work for the way I use heirloom-mailx but feel free to consult the man page and have a play with them.
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
User avatar
Posts: 480
Joined: 2008-04-22 12:08
Location: London UK

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 6 guests