My email lives on a virtual server and lately I've been accessing it with mutt on that machine via SSH. I really like mutt, but this makes things tricky when someone emails me a URL and it's either awkward to copy & paste (e.g. PuTTY) or I'd like to look at the web page on another machine--often I have my laptop to one side for email while doing other things on my desktop machine.
Mutt uses the rather nice urlview program to extract URLs out of email messages for easy selection. urlview's handler script can also be hijacked to do whatever you want. I've set mine up to generate an HTML file in the server's webspace. This HTML file has a meta refresh tag to immediately redirect the browser to the URL of interest.
Now when I get a URL in an email I hit ^b to invoke urlview, select the URL I want, load a web browser on the target machine and choose my bookmark for my own URL redirector.
To set this up yourself:
- Install the urlview package
aptitude install urlview
- Modify /etc/urlview/url_handler.sh to call your own script. I put the following line under the user-configurable settings but before their own handler:
/usr/local/bin/sharelink.sh $1
- (Optional) Disable the http handler so that you don't end up loading elinks or something else on the computer running mutt:
http_prgs=""
- Create a world-writable file in the machine's webspace: (but not world-deletable! The parent directory should only be writable by www-data or root.)
touch /var/www/link.htm chmod 0666 link.htm
- Create a script to generate that link.htm. In my case I used this following in /usr/local/bin/sharelink.sh:
#!/bin/bash LINKFILE=/var/www/link.htm url=$1 cat > $LINKFILE <<EOF <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head><title>Email Link Redirector</title> <meta http-equiv="refresh" content="0; URL=$url"></head> <body><h1>Redirecting</h1><p><a href="$url">$url</a></body> </html> EOF
Coming up with a cool way of retrieving attached files is left as an exercise to the reader.

