Paul Labis: This is a personal blog where everyone can read my experiences, ideas and thoughts about programming, latest gadgets and other information technology related topics, lifestyle and many other stuff I would like to share to the public.

Commons Email - Examples

I found another good apache tool for sending emails.
Its easy to use and has good documentation.
Below is an example of an easy way to sending an email.
It is explained properly on apache user guide page which is embedded on the bottom part of this article.


import org.apache.commons.mail.*;
...

// Create the attachment
EmailAttachment attachment = new EmailAttachment();
attachment.setPath("mypictures/john.jpg");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("Picture of John");
attachment.setName("John");

// Create the email message
MultiPartEmail email = new MultiPartEmail();
email.setHostName("mail.myserver.com");
email.addTo("jdoe@somewhere.org", "John Doe");
email.setFrom("me@apache.org", "Me");
email.setSubject("The picture");
email.setMsg("Here is the picture you wanted");

// add the attachment
email.attach(attachment);

// send the email
email.send();


Sending Mail with SMTP

I was was having problem on sending emails through Java.
I researched and found this apache API SMTP for sending email.
I just want to share this simple tutorial article on Discursive blog to everyone who needs it.

10.16. Sending Mail with SMTP | Discursive

Check Ubuntu laptop temperature

I noticed my laptop temperature is getting hotter. I was a bit worried so I made a little research on how to check the temperature via the internal chip sensors and Ubuntu terminal/command line. The quickest way so far is through below:

1. Make sure you lm-sensors are already installed. (In latest version as of 2010 - this was already configured) To know more about it goto http://packages.ubuntu.com/lucid/lm-sensors

2. Open you terminal/command line and enter the command "sudo sensors-detect". You will be asked which hardware sensors to scan. Answer it yes or no.

3. Get the temperature by running command "sensors" on your terminal.

There we have it! Thats how I check my laptop temperature. There other ways to check and are probably better and accurate. Have fun and enjoy.