Linux Blog

Thunderbird localmail Spool

Filed under: Linux Software — TheLinuxBlog.com at 1:13 pm on Friday, July 3, 2009

Thunderbird

I was in a bit of a bind the other day when I learned that an IMAP server I was using was going to dissapear. I wanted to backup all of my mail, but had too many messages hosted on the IMAP server to copy from one to another, so I decided I’d download them all locally first and then deal with them later. I used fetchmail to download all of my messages from the IMAP main folder to my local spool, and copied over all of the sub folders because I was in a rush and needed to copy them quickly.

Once they were in my local mail spool, I wanted to get them into Thunderbird, but learned that the option I had once used to read my localmail had gone. There used to be an option for it in the GUI, but somewhere along the line it got removed. After a bit of Googling, I found: http://lists.freebsd.org/pipermail/freebsd-questions/2003-December/027652.html

This worked for me, and should work for any one that wants to use Thunderbird to read local mail.

Basically, you add a new mail account in Thunderbird as usual, then close it. Get into your local profile directory by using

cd .thunderbird/[tab]
 
then
 
vi prefs.js

find your new mail server, with the bogus name and change the hostname to localhost, change your name to <yourusername>@localhost, the server type to movemail, and change the userName to your username. It should look something like the following:

user_pref("mail.server.server4.hostname", "localhost");
user_pref("mail.server.server4.name", "owen@localhost");
user_pref("mail.server.server4.type", "movemail");
user_pref("mail.server.server4.userName", "owen");

Once thats done, you can restart Thunderbird and fetch your mail as usual. From there you can do as you wish with your messages.

Excellent! My question really is why was the GUI option removed from Thunderbird? Whatever the answer this method still works, so if you need to, use it while you still can!

When Photoshop Fails

Filed under: General Linux,Shell Script Sundays — TheLinuxBlog.com at 9:50 pm on Monday, January 15, 2007

I was recently assigned the task of reducing the quality of over 1000 images. My first instinct was to use photoshop’s batch functions to complete the task. After playing around with it for a little while it became apparent that you cannot save files for web with spaces in. Photoshop had failed me. My next idea was to use a bash script to loop over every file and process the image. This was sure to work. Since I have prior experience with image processing I decided to use ImageMagick to complete the task. The command to adjust the quality is:

1
convert (FILENAME) -quality 50 (FILENAME)

This command is useless on its own so using a for loop I came up with:

1
2
3
4
#!/bin/bash
for i in $(ls); do
convert $i -quality 50 $i
done

This script would have worked for me if there were no spaces in the filenames. Because there were it took each filename that had spaces and ran the command on each part of the file name. Unfortunately this was not going to work.

After googling for a while it became apparent that I was not the only person to have the problem of spaces in filenames with for loops. The solution I found was to use the find command and a while loop. Below is working script that successfully completed the task in no time:

1
2
3
4
5
#!/bin/bash
find * -iname "*" | \
while read I; do
convert "$I" -quality 50 "$I"
done

This script could be easily modified to take advantage of ImageMagick’s many other functions. For example it could be used to batch resize a folder of images to make thumbnails by changing the command to:

1
convert "$I" -resize 200 "$I"

Or it could be used to overlay text onto an image with the following command:

1
convert "$I" -gravity southeast -annotate +5+10 "thelinuxblog.com" -fill black "$I"

As shown above ImageMagick is really powerful image editing software which can easily be used with the bash shell to process thousands of images with no trouble.