View Single Post
Old 09-10-2011, 09:30 PM   #1
the_vorpal_blade
Junior Member
the_vorpal_blade plays well with othersthe_vorpal_blade plays well with othersthe_vorpal_blade plays well with othersthe_vorpal_blade plays well with othersthe_vorpal_blade plays well with othersthe_vorpal_blade plays well with othersthe_vorpal_blade plays well with othersthe_vorpal_blade plays well with othersthe_vorpal_blade plays well with othersthe_vorpal_blade plays well with othersthe_vorpal_blade plays well with others
 
Posts: 3
Karma: 2600
Join Date: Sep 2011
Device: kindle
mutt e-mail client on the kindle

Hey Folks,
I've been lurking for a bit, but this is my first post :-)

I recently got mutt working and configured on the kindle, and thought I'd share:

DISCLAIMER:
Running a mail client on the kindle means making the root filesystem writable by default. This is dangerous. If you fill up your root partition, you risk making your kindle unbootable!


Notes:
1. Wherever I put something in <brackets> I intend you to substitute your
own value. I most often use this for <username> and <password>
2. Although you could go through most of this guide without logging in to your kindle via usb networking or ssh over wifi, it is much easier if you do most of the below while logged in from your computer.
this link:
http://www.mobileread.com/forums/sho...85&postcount=8
has instructions for connecting via ssh over wifi and making the sshd start at boot. Authenticating via key rather than username and password, is, of course, not essential, but you should probably change the default root password using
Code:
passwd
first.


Step 1:
Jailbreak your kindle. I used:
http://yifan.lu/p/kindle-jailbreak

Step 2:
Install usbNetwork Hack and native kindle terminal. I used:
http://www.mobileread.com/forums/sho...d.php?t=125860
which links here:
http://info.iet.unipi.it/~luigi/kind...indle-terminal

Step 3:
Install optware. I used:
http://www.mobileread.com/forums/sho...d.php?t=118472
This script looks promising, but it failed for me on a hash check:
https://gist.github.com/791141

Step 4:
Set up your path. I changed relevant line in /etc/profile from:
Code:
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/sbin:/sbin
to:
Code:
export PATH=/opt/bin:/opt/sbin:/usr/local/bin:/bin:/usr/bin:/usr/sbin:/sbin
Step 5:
set up a user account
Code:
mkdir -p /home/<username>
adduser <username> (and follow the prompts)
chown <username> /home/<username>
chgrp <username>  /home/<username>
step 6:
use ipkg to install the appropriate mail utilities. vim and sudo are not strictly essential to this setup, but are helpful.
Code:
ipkg install mutt fetchmail procmail msmtp sudo vim
step 6.5:
if you installed sudo, add yourself to the sudoers file.
Code:
visudo
then change:
Code:
root ALL=(ALL) ALL
to:
Code:
root ALL=(ALL) ALL 
<username> ALL=(ALL) ALL
step 7:
fix the kindle's strange permissions
Since the kidnle was never really invisioned as a multi-user device, the
permissions on things like /dev/null and /dev/random are tighter than they really should be. So, fix that:
Code:
chmod a+rw /dev/null
chmod a+rw /dev/random
chmod a+rw /dev/urandom
you can either do this every time you reboot the kindle, or make it permanent, but putting it in an init script.
To put it in an init script, do something like:
Code:
vim /etc/init.d/fixperms
then put in:
Code:
#!/bin/sh
#a script for making the kindle more multi-user friendly
mntroot rw
chmod a+rw /dev/null
chmod a+rw /dev/random
chmod a+rw /dev/urandom
then to make it run at boot
Code:
chmod +x /etc/init.d/fixperms
ln -s /etc/init.d/fixperms /etc/rc.5/S99fixperms
Step 8:
Logging in
Code:
login
Then put in your username and password.

Step 9:
Configuring mutt
(Most of this came from http://www.andrews-corner.org/mutt.html )
Put the following in your ~/.muttrc file, in your home directory
Code:
# Colors Generated by the muttrc builder (http://muttrcbuilder.org/)
# for mutt-1.5.18

# Colors
# We set all the colors to black on while for maximum kindle readability
color attachment black        white
color error      black        white
color hdrdefault black        white
color indicator  black        white
color markers    black        white
color message    black        white
color normal     black        white
color quoted     black        white
color search     black        white
color signature  black        white
color status     black        white
color tilde      black        white
color tree       black        white

#The rest of the config taken from http://www.andrews-corner.org/mutt.html
#======================================================#
# Boring details
# I use Gmail, so this configuration caters to that.
set realname = "<Your Name>"
set from = "<gmail username>@gmail.com"
set use_from = yes
set envelope_from ="yes"

# Use a signature
set signature="~/.signature"

# Use msmtp rather than sendmail. Check that 
# the path is correct for your system:
set sendmail="/opt/bin/msmtp"

# If not set in ~/.bashrc:
set spoolfile = "/opt/var/spool/mail/<username>"

#======================================================#
# Folders
set folder="$HOME/mail"      # Local mailboxes stored here
set record="+sent"           # Where to store sent messages
set postponed="+postponed"   # Where to store draft messages
set mbox_type=mbox           # Mailbox type
set move=no                  # Don't move mail from spool

#======================================================#
# Watch these mailboxes for new mail, useful only if 
# Procmail or Maildrop is used to sort mail.
mailboxes ! +slrn +fetchmail +mutt
set sort_browser=alpha    # Sort mailboxes by alpha(bet)

#======================================================#
# What to show and order of headers
ignore *
unignore Date: From: User-Agent: X-Mailer X-Operating-System To: \
         Cc: Reply-To: Subject: Mail-Followup-To:
hdr_order Date: From: User-Agent: X-Mailer X-Operating-System To: \
         Cc: Reply-To: Subject: Mail-Followup-To:

#======================================================#
# which editor do you want to use? 
# vim of course!
set editor="vim -c 'set tw=70 et' '+/^$' "
set edit_headers=yes      # See the headers when editing

#======================================================#
# Aliases

set alias_file = ~/mail/mutt_aliases # In their own file
source ~/mail/mutt_aliases           # Source them
set sort_alias=alias                 # Sort alphabetically


#======================================================#
# Odds and ends

set markers          # mark wrapped lines of text in the pager with a +
set smart_wrap       # Don't wrap mid-word
set pager_context=5  # Retain 5 lines of previous page when scrolling.
set status_on_top    # Status bar on top.
push <show-version>  # Shows mutt version at startup
We also have to make the mail directory, so in your home directory
Code:
mkdir ~/mail
touch ~/mail/mutt_aliases
Step 10
Configuring fetchmail
Put the following in .fetchmailrc in your home directory
Code:
poll imap.gmail.com 
protocol IMAP 
user "<your gmail address>" 
there with password <your gmail password>"
nofetchall
mda "/opt/bin/procmail -d %T"        
ssl
sslcertck
sslcertfile /etc/ssl/certs/ca-certificates.crt
keep
Since your password is in the file, we may as well chmod it
Code:
chmod 600 .fetchmailrc
Step 11:
Configuring procmail
Put the following in ~/.procmailrc
Code:
PATH=/opt/sbin:/opt/bin:/bin:/usr/bin:/usr/local/bin
VERBOSE=off
DEFAULT=/opt/var/spool/mail/matthew
MAILDIR=$HOME/mail
LOGFILE=$HOME/.procmaillog
# Recipes below this comment:
Now we need to make the spool file.
Code:
sudo mkdir -p /opt/var/spool/mail/
sudo chmod a+rw /opt/var/spool/mail/
step 12:
Configuring msmtp
Put the follwoing in ~/.msmtprc

Code:
account default              
host smtp.gmail.com          
port 587                     
from <gmail address>     
tls on                       
tls_starttls on              
tls_trust_file /etc/ssl/certs/ca-certificates.crt
auth on                     
user <gmail username>      
password <gmail password>     
logfile ~/.msmtp.log
At this point everything should work.
To check for new messages, run fetchmail, to read them, run mutt.
you can even run fetchmail from within mutt with
Code:
!fetchmail
Bugs/things I with were better about my setup::
Ideally, I'd like to put the spool folder on /mnt/us/ somewhere,
so that there is no chance of it filling up the root filesystem. However,
I can't seem to make /mnt/us/ writable to an ordinary user.

My script for fixing permissions on boot time only seems to work sometimes. I don't know why.

When logging in via ssh, I can only log in as user: root, then I can run login to get to my user. I don't know why.

When starting the standalone kindle terminal, /etc/profile is not read, and login is not called. Ideally, when that terminal started, it would call login, but I don't know how to make it do that either.

Any suggestions for improvements are welcome :-)

-Matthew
the_vorpal_blade is offline   Reply With Quote