Send E-Mail using JavaMail from behind a proxy server

If you trying to send an email using JavaMail API from behind a proxy server you would get ‘UnknownHostException’ . Thats because the proxy server doesn’t allow SMTP traffic through it.

One of my friend Indika Tantrigoda suggested me a forum thread that contains a good solution for this.

So this is the forum link

I think you may find a better answer…



Send E-mail with attachments using JavaMail

As I promised in my earlier post ‘Send E-mail using JavaMail API and your GMail account’ I’ll show you how to send an email with an attachment using JavaMail API (

Basic steps are similar to my previous post . So before proceed with this one, I recommend you to refer my previous article, in order to get a basic idea.

If you need to send an email with an attachment, first you need to construct a MimeMultipart message. MimeMultipart message is composed of MimeBodyPart messages. You can attach your file in to MimeBodyPart message and then MimeBodyPart can be further added to MimeMultipart message. Finally MimeMultipart message can be added to basic MimeMessage by calling its setContent (MimeMultipart message) method.

This relationship is illustrated below.

Hierarchical view of different messages
Hierarchical view of different messages

You can download the complete source code for the application here

Add ‘Open Terminal’ to Gnome context menu in Ubuntu

Gnome ships with the absence of a killer desktop tweak called ‘Open Terminal’. This simple feature lets you open a new terminal, when you right click on a folder. I was really wondering  why this feature is not included in Ubuntu distros.

How to install it?

Open a new terminal and type

sudo apt-get install nautilus-open-terminal

Then log out and log in again to restart the Gnome. Now it should looks like this…

After installing 'Open Terminal'
After installing 'Open Terminal'